我使用sudo easy_install python-jenkins
在mac上安装了jenkins软件包。安装顺利,没有错误,但是当我打开python并输入import jenkins
时,我收到以下错误。
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
谷歌搜索这并没有产生任何有用的结果。
修改后追溯
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
答案 0 :(得分:3)
有问题的模块与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() == 'Darwin':
开关可以跨平台保持可加载的东西。
更新:实际上,模块固执地希望lookup3.so
模块位于site-packages
目录中,而不是模块本身。因此,它不是easy_install兼容的。将所有文件(未更改)从.egg
目录直接移动到/Library/Python/2.7/site-packages/
目录中时,它将起作用。
答案 1 :(得分:0)
OSError:dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lookup3.so,6):找不到图片
在目录中,
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
,
ln -s lookup3.cpython-36m-darwin.so lookup3.so
为我工作。
答案 2 :(得分:0)
我发现lookup.so jenkins.py正在尝试加载:
/Users/MY-USER/Documents/Telnyx/dev/tdm-get-ips/venv/lib/python3.7/site-packages/lookup3.cpython-37m-darwin.so
所以我改变了
python3.7/site-packages/jenkins.py
行:
lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.so"))
针对:
lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.cpython-37m-darwin.so"))
它开始正常工作。