2015-04-16 126 views
2

我想使用pyunpack unrar文件,但我總是得到一個錯誤。 如果我使用一個zip文件,一切正常,但沒有rar文件。 這是我的代碼:解壓rar文件在Python中的錯誤

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> 

你有什麼可能是問題的任何想法?

+0

嘗試安裝'patool'軟件包。沒有它,只有zip文件可以解壓縮。 – fenceop

+1

已經做到了。 「再次安裝patool」,它說「要求已經滿足」,所以我認爲這不是問題。 –

+0

我得到同樣的錯誤,我不知道是什麼原因造成的,對不起。 – fenceop

回答

1

這個問題可能是你沒有你的unraring工具路徑,這意味着它不能從從命令行調用(這是exacly什麼patool一樣)。只要把你的7-zip(或其他你正在使用的)文件夾放到路徑中就行了。