gpt4 book ai didi

python - 在 Python 错误中解压缩 rar 文件

转载 作者:太空宇宙 更新时间:2023-11-04 05:52:14 25 4
gpt4 key购买 nike

我正在尝试使用 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>

您知道可能是什么问题吗?

最佳答案

问题可能是您的路径中没有解压缩工具,这意味着它不能从命令行调用(这正是 patool 所做的)。只需将您的 7-zip(或您正在使用的任何其他内容)文件夹放入路径即可。

关于python - 在 Python 错误中解压缩 rar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29677998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com