Error when Python rarfile decompresses. Rar file: badrarfile

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: