I am using ubuntu 20.04 to write python programs. I usually install python packages without the sudo
prefix. But I noticed that if I go into the sudo mode and then try to import a previously installed python package, it would raise ModuleNotFoundError: No module named 'xxx'
. But if I exit the sudo mode everything will be alright again.
What could be the reason? Could it be because in sudo mode the import path is not added to the PATH
variable? But that doesn't seem to be the reason if you check my PATH
variables below:
Normal user mode:
/usr/local/cuda-10.2/bin:/home/myusername/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Root mode:
/usr/local/cuda-10.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:
pip
(orpip3
)?