0

我使用 Activepython 安装了 rarfile 库(我正在使用 mac os 和 eclipse),尽管 everyhting 似乎已正确安装,但我仍然通过简单的提取测试继续收到此错误消息:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.py", line 1843, in custom_popen
    raise RarExecError("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
rarfile.RarExecError: Unrar not installed? (rarfile.UNRAR_TOOL='unrar')

我检查了 rarfile 库在我的计算机上的安装位置,并使用以下路径在 Eclipse(Window -> Preferences -> Pydev -> Interpreter - Python -> System PYTHONPATH)上的包含文件中定义了库路径:

/Bibliothèque/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile-2.6-py2.7.egg-info

/Bibliothèque/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.py

/Bibliothèque/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.pyc

/Bibliothèque/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.pyo

我仍然收到此错误消息:

File "/Users/moi/Documents/workspace/Apprentissage/Dezipper/test_rarfile_2.py", line 3, in <module>
    ref.extractall('/Users/moi/Downloads/_zips/rars/')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.py", line 675, in extractall
    self._extract(fnlist, path, pwd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.py", line 1202, in _extract
    p = custom_popen(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rarfile.py", line 1843, in custom_popen
    raise RarExecError("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
rarfile.RarExecError: Unrar not installed? (rarfile.UNRAR_TOOL='unrar')

对这个问题有任何想法吗?非常感谢。

4

1 回答 1

1

好的,我解决了这个问题。除了在 python 中安装 rarfile 库之外,我还需要安装 unrar 库。在 mac os x 上,这可以通过在终端中执行此操作来实现:

cd /tmp
curl -o output.tar.gz http://www.rarlab.com/rar/rarosx-3.9.3.tar.gz
Untar the tar ball, enter:

tar -zxvf output.tar.gz

现在,rar 已提取,我不再收到错误消息。很高兴知道。

于 2013-09-06T07:54:47.367 回答