所以我试图在Python中使用rarfile库来存档.rar文件,但它一直说“无法打开”。我使用的是Mac OS X El Capitan,python 2.7。任何帮助将不胜感激,谢谢。
原始代码:
rf = RarFile('test.rar')
rf.extractall()
错误讯息:
File "Test.py", line 271, in <module>
rf.extractall()
File "/Users/user/Library/Python/2.7/lib/python/site-packages/rarfile.py", line 679, in extractall
self._extract(fnlist, path, pwd)
File "/Users/user/Library/Python/2.7/lib/python/site-packages/rarfile.py", line 1238, in _extract
check_returncode(p, output)
File "/Users/user/Library/Python/2.7/lib/python/site-packages/rarfile.py", line 1961, in check_returncode
raise exc(msg)
rarfile.RarUnknownError: Unknown exit code [1]: bsdtar: Error opening archive: Failed to open '--'
答案 0 :(得分:4)
现在您需要为Ubuntu / Linux安装unrar
:
sudo apt-get install -y rar unrar
或MacOS的以下版本:
brew install unrar