在Python中解压缩rar文件错误

时间:2015-04-16 14:36:23

标签: python rar unrar

我正在尝试使用pyunpack解压缩文件,但我总是收到错误。 如果我使用zip文件一切正常,但rar文件不行。 这是我的代码:

from pyunpack import Archive
Archive('C:/Users/Username/Desktop/teste/Desktop2.rar').extractall('C:/Users/Username/Desktop/teste')

这是我得到的错误:

Traceback (most recent call last):
  File "c:\Python34\lib\site-packages\easyprocess\__init__.py", line 255, in start
    cwd=self.cwd,
  File "c:\Python34\lib\subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "c:\Python34\lib\subprocess.py", line 1112, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system couldn't find the specified file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Username\Documents\NetBeansProjects\Teste\src\main.py", line 17, in <module>
    Archive('C:/Users/Username/Desktop/teste/Desktop2.rar').extractall('C:/Users/Username/Desktop/teste')
  File "c:\Python34\lib\site-packages\pyunpack\__init__.py", line 81, in extractall
    self.extractall_patool(directory)
  File "c:\Python34\lib\site-packages\pyunpack\__init__.py", line 47, in extractall_patool
    ]).call()
  File "c:\Python34\lib\site-packages\easyprocess\__init__.py", line 223, in call
    self.start().wait(timeout=timeout)
  File "c:\Python34\lib\site-packages\easyprocess\__init__.py", line 260, in start
    raise EasyProcessError(self, 'start error')
easyprocess.EasyProcessError: start error <EasyProcess cmd_param=['patool', 'extract', Path('C:\\Users\\Username\\Desktop\\teste\\Desktop2.rar'), Path('--outdir=C:\\Users\\Username\\Desktop\\teste')] cmd=['patool', 'extract', Path('C:\\Users\\Username\\Desktop\\teste\\Desktop2.rar'), Path('--outdir=C:\\Users\\Username\\Desktop\\teste')] oserror=[WinError 2] The system couldn't find the specified file returncode=None stdout="None" stderr="None" timeout=False>

你对这个问题有什么想法吗?

1 个答案:

答案 0 :(得分:0)

运行 sudo apt install unrar 为我解决了这个问题。

相关问题