我使用sudo easy_install python-jenkins在Mac上安装了jenkins软件包.安装进行得很好,没有错误,但是当我打开python并输入import jenkins时,出现以下错误.
<code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.7-intel/egg/jenkins.py", line 9, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Python/2.7/site-packages/lookup3.so, 6): image not found
</code>
谷歌搜索没有产生任何有益的结果.
编辑后的回溯
<code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "jenkins.py", line 9, in <module>
lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.dynlib"))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Python/2.7/site-packages/lookup3.dynlib, 6): image not found
</code>
解决方法:
有问题的模块与Mac OS X动态库约定不兼容.
它尝试加载lookup3.so文件,但在Mac上将改为lookup3.dynlib.您可以通过查看/Library/Python/2.7/site-packages目录来验证这一点.然后,只需编辑jenkins.py模块,并将.so扩展名替换为.dynlib.
我也要向issue tracker of the module报告;一个简单的if platform.system()==’D??arwin’:开关将使内容可跨平台加载.
更新:实际上,模块顽固地期望lookup3.so模块位于site-packages目录中,而不是模块本身.因此它与easy_install不兼容.当您将所有文件(未更改)从.egg目录直接移到/Library/Python/2.7/site-packages/目录中时,它将起作用.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!