rarfile库安装异常

时间:2013-09-06 07:54:47

标签: python eclipse python-2.7

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

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上的include文件中定义了库路径(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')

对这个问题有什么看法?非常感谢。

1 个答案:

答案 0 :(得分: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被解压缩,我不再收到错误消息了。很高兴知道。