libarchive.public 即使在 python 中安装 libarchive 后仍出现错误

libarchive.public error even after installing libarchive in python

我在尝试执行 导入 libarchive.public 时遇到错误。以下是日志文本。我已经使用 pip install libarchive 安装了 libarchive。帮助命令显示库中存在 public 模块,但在导入时仍然出现错误。谁能帮我解决这个错误是什么。我想我做对了一切。


WindowsError                              Traceback (most recent call last)
<ipython-input-10-bd7a0027d55f> in <module>()
----> 1 import libarchive.public

C:\Users\soumya\AppData\Local\Enthought\Canopy\User\lib\site-packages\libarchive\public.py in <module>()
----> 1 from libarchive.adapters.archive_read import       2     file_enumerator, file_reader, file_pour,       3     memory_enumerator, memory_reader, memory_pour
      4 
      5 from libarchive.adapters.archive_write import 
C:\Users\soumya\AppData\Local\Enthought\Canopy\User\lib\site-packages\libarchive\adapters\archive_read.py in <module>()
      5 import libarchive.constants.archive
      6 import libarchive.exception
----> 7 import libarchive.calls.archive_read
      8 import libarchive.calls.archive_write
      9 import libarchive.calls.archive_general

C:\Users\soumya\AppData\Local\Enthought\Canopy\User\lib\site-packages\libarchive\calls\archive_read.py in <module>()
      1 from ctypes import *
      2 
----> 3 from libarchive.library import libarchive
      4 from libarchive.types.archive import *
      5 from libarchive.constants.archive import *

C:\Users\soumya\AppData\Local\Enthought\Canopy\User\lib\site-packages\libarchive\library.py in <module>()
     14 
     15 _logger.debug("Using library: [%s]", _FILEPATH)
---> 16 libarchive = ctypes.cdll.LoadLibrary(_FILEPATH)

C:\Users\soumya\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.1.2730.win-x86_64\lib\ctypes\__init__.pyc in LoadLibrary(self, name)
    441 
    442     def LoadLibrary(self, name):
--> 443         return self._dlltype(name)
    444 
    445 cdll = LibraryLoader(CDLL)

C:\Users\soumya\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.1.2730.win-x86_64\lib\ctypes\__init__.pyc in __init__(self, name, mode, handle, use_errno, use_last_error)
    363 
    364         if handle is None:
--> 365             self._handle = _dlopen(self._name, mode)
    366         else:
    367             self._handle = handle

WindowsError: [Error 126] The specified module could not be found 
I had to do it on Linux Mint as I could not find a solution for windows. The modified answer is below.

# Install compiler and tools
$ sudo apt-get install build-essential libtool python-dev

# Install cmake
$ sudo apt-get install cmake

$ wget https://github.com/libarchive/libarchive/releases/download/v3.4.1/libarchive-3.4.1.tar.xz
$ tar -xJf libarchive-3.4.1.tar.xz

# Configure using cmake...
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../libarchive-3.4.1

# Now compile and install...
$ make
$ sudo make install

$ sudo sh -c 'echo /usr/local/lib > /etc/ld.so.conf.d/libarchive3.conf'
$ sudo ldconfig

$pip install python-libarchive

最新的 libarchive 下载 link 可在此 URL 找到:http://www.linuxfromscratch.org/blfs/view/svn/general/libarchive.html