1

libarchive的发行说明指出,由于旧版本的 libarchive 包含在 MacOS 中,他们建议更改 LD_LIBRARY_PATH 以指向最近的 libarchive 副本的位置。

我已使用此代码尝试实现这一目标,但在运行脚本时收到错误消息。

import os

print os.environ.get('LD_LIBRARY_PATH') #Check what the current path is 

os.environ['LD_LIBRARY_PATH'] = '/Library/Python/2.7/site-packages/'
print os.environ.get('LD_LIBRARY_PATH') #Check the variable has been set 

import libarchive.public

错误:

None
/Library/Python/2.7/site-packages/
Traceback (most recent call last):
  File "scratch.py", line 8, in <module>
    import libarchive.public
  File "/Library/Python/2.7/site-packages/libarchive/public.py", line 1, in <module>
    from libarchive.adapters.archive_read import \
      File "/Library/Python/2.7/site-packages/libarchive/adapters/archive_read.py", line 7, in <module>
    import libarchive.calls.archive_read
  File "/Library/Python/2.7/site-packages/libarchive/calls/archive_read.py", line 17, in <module>
c_archive_read_support_filter_all = libarchive.archive_read_support_filter_all
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fb08b741000, archive_read_support_filter_all): symbol not found

我在外面的任何地方都找不到很好的答案。

4

1 回答 1

3

从工具文档中不清楚,但基于一个线程:https ://github.com/dsoprea/PyEasyArchive/issues/16我将另一个环境变量设置为可以找到底层c库的位置。就我而言,它是由我的 Mac 上的自制软件放在那里的。

os.environ['LA_LIBRARY_FILEPATH']='/usr/local/opt/libarchive/lib/libarchive.dylib'

import libarchive.public

为我工作。

于 2018-05-04T14:09:30.353 回答