“applepython”:OSError:dlopen(libps2000a.dylib,6):在IPython中找不到映像

2024-10-04 01:37:26 发布

您现在位置:Python中文网/ 问答频道 /正文

在Macos上,我用如下方式设置DYLD_LIBRARY_PATH

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

如果我在IPython中运行这两行代码,它会起作用:

^{pr2}$

但是我在标准的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:我认为它与苹果提供的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变量相同

我该怎么做才能“告诉”苹果Python“看到”DYLD_LIBRARY_PATH?在


Tags: pathinbininitlibusrlinelibrary