“苹果的Python”:OSERROR:执行dlopen(libps2000a.dylib,6):没有找到图片,但不是在IPython中
问题描述:
在MacOS,我已经设置DYLD_LIBRARY_PATH
这样:“苹果的Python”:OSERROR:执行dlopen(libps2000a.dylib,6):没有找到图片,但不是在IPython中
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:我THI NK它有什么用苹果提供的,因为与/usr/local/bin/python2
(由brew
工具提供),它的工作原理的Python:
$ /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
可变
我能做些什么来“告诉”“苹果的Python”到“看” DYLD_LIBRARY_PATH
?
答
MacOS X上它是DYLD_LIBRARY_PATH
不LD_LIBRARY_PATH
。
对环境变量可以设置影响动态连接器的详细信息请参见dyld
手册页。
我有同样的PB。用'DYLD_LIBRARY_PATH'变量 – SebMa
你能读我的'EDIT2'吗? – SebMa
你是否已经通过使用'import os; os.environ [ 'DYLD_LIBRARY_PATH']''? –