Problem with "import rarfile" in python on Ubuntu

1.3k Views Asked by At

Today I turned on my Ubuntu virtual machine and tried to do a project in Python 3.9.4,
but this one used rarfile module. Which is throwing errors.

import rarfile doesn't work

I know rarfile uses unrar, and I installed both rarfile and unrar. Tried to type unrar seperately and it works.

but unrar does work on itself

I almost spent whole day trying to figure this out.

My question is why does importing rarfile module not work, and how can I fix it.
I also read online it could have something to do with PATH, but I am pretty new to linux and don't know terminology of it and therefore don't know how to try to fix it.
Some information regarding that would probably help if not now, for the future problems regardless if it is connected to this problem or not.

Sorry if I formatted this post poorly, it's my 2nd post on here.

1

There are 1 best solutions below

1
On

I would do pip install rarfile to make sure it is install also you may want to do a pip list to make sure its intalled. Also if python 2 is install then most likly you need to do pip3 install rarfile.