Python decompresses the. Rar file using the rarfile module. An error is reported:
raise BadRarFile("Failed the read enough data: req=%d got=%d" % (orig, len(data)))
rarfile.BadRarFile: Failed the read enough data: req=1151 got=52
Solution:
install the necessary modules:
pip install rarfile
pip install unrar
Download: unrar.exe
link: https://pan.baidu.com/s/1St0XHD3wMB8v6CrDsvLK4g
Extraction code: 9hr5
Put unrar.exe in the same record as the PY file you wrote, and you can successfully run and unzip the rar file.
The reason is probably:
the algorithm of RAR compression package is not open source and is not disclosed to the public. Therefore, if other software wants to compress or decompress rar files, it must call rar.exe through CMD. Therefore, it is suspected that rarfile is actually called rar.exe or unrar.exe
Reference:
unzip the rar file in Python
unzip the rar file in Python
Read More:
- Using Unrar to decompress rar file
- Solution to “An error occurred while loading the archive” appears when decompressing the rar file compressed package
- Python read / write file error valueerror: I/O operation on closed file
- When Python Django creates a database, can’t open file ‘ manage.py ‘: [Errno 2] No such file or directory
- Python reports oserror: initializing from file failed
- Python — magic identify file types
- Python how does a. Py file call classes and functions in another. Py file
- Python failed to read TIF file exported by envi.
- python reads csv file is an error _csv.Error: iterator should return strings, not bytes (did you open the file in text)
- No code, a solution to the error in the path of reading CSV file by Python: filenotfounderror: [errno 2] no such file or directory: ‘XX. CSV‘
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Fatal Python error: initfsencoding: unable to load the file system codec
- fatal error: Python.h: No such file or directory
- fatal error: Python.h: No such file or directory
- fatal error: Python.h: No such file or directory compilation terminated.
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- Fatal error in CentOS: Python. H: no that file or directory
- Python reads the configuration file. Ini and resolves the error
- Fatal Python error: Py_Initialize: unable to load the file system codec.