python not importing module— perhaps gcc being use

2019-06-01 01:14发布

问题:

Mac OSX here, Python 2.7.9 |Anaconda 2.2.0 (x86_64)|. I'm trying to install a python module called, say, foo. I run

python setup.py install

I get

running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /Users/jir955/anaconda/lib/python2.7/site-packages/kenlm-0.0.0-py2.7.egg-info
Writing /Users/jir955/anaconda/lib/python2.7/site-packages/kenlm-0.0.0-py2.7.egg-info

However, after

import foo

I get the error

  Traceback (most recent call last): File "<stdin>", 
line 1, in <module> ImportError: foo.so, 2):
 Symbol not found: __ZTINSt8ios_base7failureB5cxx11E
Referenced from: foo.so Expected in: dynamic lookup

Errors in the past have occurred when I tried to compile something with gcc instead of clang. (At some point I downloaded gcc on my own, for some reason, but then I brew uninstalled gcc.) I have avoided the errors by sometimes adding -toolset=clang.

I have tried adding

 os.environ["CC"] = "/usr/bin/clang"
 os.environ["CXX"] = "/usr/bin/clang"

to setup.py, and also modifying bashrc to include

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

But these things have not worked. One person I talked to suggested that the problem was that I compiled python libraries using gcc instead of clang, but if this is the case I don't know how how to fix that either.

Edit: with

nm foo.so

an excerpt of what I get is

0000000000072a60 S __ZTIN4util9ExceptionE
U __ZTINSt8ios_base7failureB5cxx11E
U __ZTISt11range_error