"pip install jep"收到错误"ld: library not found for -lpython2.7"



==环境

  • Mac OSX 10.9.1
  • 已安装python 2.7.3、python 3.3
  • python安装目录:/Library/Frameworks/Python.framework

我尝试使用pip install jep安装jep

但是我收到一个错误

`ld: library not found for -lpython2.7`

我尝试添加/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib至$PATH

但它不起作用。

有人能解决这个问题吗?

快速查看jep,它在setup.py中的安装过程似乎对在哪里可以找到要链接的Python解释器共享库做出了一些简化和错误的假设。在OSX上,它似乎允许库默认搜索路径默认为标准库路径,包括/usr/lib。如果您没有使用系统提供的Python之一,就像您的情况一样,那么在那里找不到正确的库。jep应该做的是使用与正在使用的编译器相对应的python-config命令来查找共享库位置;例如,如果使用python.org 2.7:

$ /usr/local/bin/python2.7-config --ldflags
-L/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
-ldl -framework CoreFoundation -lpython2.7

我还猜测您还没有在OSX10.9中为Xcode 5安装完整的Xcode命令行工具包,因此/usr/lib中没有libpython2.7.dylib。如果您这样做,请运行:

xcode-select --install

现在,您将找到libpython2.7.dylib的符号链接,如果重新运行pip install jep,您将不再得到library not found错误。但是,jep扩展模块现在将链接到系统Python 2.7,而不是您安装的较新的Python 2.7。

$ otool -L /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jep.so
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jep.so:
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

应该是/Library/Frameworks/Python.framework/Versions/2.7/Python

我建议您在jep项目错误跟踪器上打开一个问题来修复这个问题。

相关内容

最新更新