Im trying to unpack a 7z file but got an error.
This is the code:
from pyunpack import Archive
Archive('E:/Desktop/vnpt2/2_1_0_2841.7z').extractall('E:/Desktop/vnpt2/new')
And this is error:
Traceback (most recent call last):
File "E:\Desktop\vnpt2\zip.py", line 2, in <module>
Archive('E:/Desktop/vnpt2/2_1_0_2841.7z').extractall('E:/Desktop/vnpt2/new')
File "C:\Python27\lib\site-packages\pyunpack\__init__.py", line 90, in extractall
self.extractall_patool(directory, patool_path)
File "C:\Python27\lib\site-packages\pyunpack\__init__.py", line 62, in extractall_patool
raise PatoolError('patool can not unpack\n' + str(p.stderr))
pyunpack.PatoolError: patool can not unpack
patool error: error extracting E:\Desktop\vnpt2\2_1_0_2841.7z: could not find an executable program to extract format 7z; candidates are (7z,7za,7zr),
How can I fix it?
WinZip opens and extracts 7z Compressed Archive Files—and many more formats.
If you've come across a file that ends in “. 7z”, you're probably wondering why you can't open it. These files, known as “7z” or “7-Zip files,” are archives of one or more files in one single compressed package. You'll need to install an unzipping app to extract files from the archive.
You can instead use the combination of py7zr
package and shutil
package to unzip 7z file.
Steps
Pip install py7zr
Run the below code:
from py7zr import unpack_7zarchive
import shutil
shutil.register_unpack_format('7zip', ['.7z'], unpack_7zarchive)
shutil.unpack_archive('filename.7z', '/unzip_path')
If you are using Mac OS, install 7zip with command
brew install p7zip
On windows download and install 7zip from https://www.7-zip.org/download.html
Then update the PATH variable to point the directory containing 7za.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With