在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
EDIT1:我认为它与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>
EDIT2:我有同样的pb。使用DYLD_LIBRARY_PATH
变量与LD_LIBRARY_PATH
变量
我该怎么做才能“告诉”“Apple Python”“看到”DYLD_LIBRARY_PATH
?
答案 0 :(得分:1)
在MacOS X上,DYLD_LIBRARY_PATH
不是LD_LIBRARY_PATH
。
有关可以设置的影响动态链接器的环境变量的详细信息,请参见dyld
的手册页。