What I observed.
I just ran a Python script which imports a module called "toml" and it had been installed with pip install toml command. Its installation path was under "/usr/local/lib/python3.9/site-packages" which seemed OK. However, when I ran the script it just kept complaining about "MODULE NOT FOUND".
What solved the problem
After some googling I found out the reason behind this was that I didn't have enought permission to import this module. I ran the script again with "SUDO" and it worked!
What confuses me
- I never intsalled toml with
SUDObut I need to use it to run a Python script, huh? chmod 777 /usr/local/lib/python3.9/site-packagesdidn't solve this problem. That's strange! I thoughtchmod 777was gonna fix any permission problem.- Using
python -m pip install tomland I can run this script without using SUDO. Is it a best practice to install Python modules withpython -m pip install?