Rarfile python module keeps throwing an error when trying to extract contents from a *.rar file
So im trying to simply extract the contents of a rar file into another location-
import rarfile epath='C:\\Users\\sidharth.m\\Desktop\\Rar\\xyz.rar' def unrar(file): rf = rarfile.RarFile(file) rf.extractall() unrar(epath)
But im getting the following error -
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\rarfile.py", line 2816, in custom_popen raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL) rarfile.RarCannotExec: Unrar not installed? (rarfile.UNRAR_TOOL='unrar')
Ive already tried adding and installing the rarfile and unrar packages through anaconda prompt and cmd, ive also added their respective paths into the environmental path variables and if that wasnt enough i even imported them into the project folder.
Any idea why this problem could be happening?
import rarfile rarfile_full_path='PATHTOFILE\\xyz.rar' path_to_extract='NEW_PATH_OF_YOUR_CHOICE' def unrar(file,path): rf = rarfile.RarFile(file) rf.extractall(path) unrar(rarfile_full_path,path_to_extract)
And you need to install unrar or bsdtar on your machine; just the rarfile python package is not enough
From the API Doc:
Compressed files are extracted by executing external tool: either unrar from RARLAB or bsdtar from libarchive.
Ive already tried adding and installing the rarfile and unrar packages through anaconda prompt and cmd
Check if you can unrar from your cmd first, outside of python