"Apple Python":OSError:dlopen(libps2000a.dylib,6):找不到图像,但在IPython中找不到



在Macos上,我以这种方式设置DYLD_LIBRARY_PATH

export DYLD_LIBRARY_PATH=/Applications/PicoScope6.app/Contents/Resources/lib

如果我在 IPython 中运行这两行,它可以工作:

from ctypes import cdll
cdll.LoadLibrary("libps2000a.dylib")

但我在标准 python 解释器中运行它们,我得到:

$ /usr/bin/python
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("libps2000a.dylib")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libps2000a.dylib, 6): image not found

编辑1 :我认为它与Apple提供的Python有关,因为使用/usr/local/bin/python2(由brew实用程序提供(,它可以工作:

$ /usr/local/bin/python2
Python 2.7.13 (default, Jul 18 2017, 09:17:00)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("libps2000a.dylib")
<CDLL 'libps2000a.dylib', handle 7f8838d01f80 at 10b438f50>

编辑2:我对DYLD_LIBRARY_PATH变量与LD_LIBRARY_PATH变量具有相同的pb。

我该怎么做才能"告诉"苹果蟒蛇"看到"DYLD_LIBRARY_PATH

在MacOS X上,它DYLD_LIBRARY_PATH不是LD_LIBRARY_PATH

有关可以设置的会影响动态链接器的环境变量的详细信息,请参见dyld手册页。

相关内容

最新更新