0

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

  1. I never intsalled toml with SUDO but I need to use it to run a Python script, huh?
  2. chmod 777 /usr/local/lib/python3.9/site-packages didn't solve this problem. That's strange! I thought chmod 777 was gonna fix any permission problem.
  3. Using python -m pip install toml and I can run this script without using SUDO. Is it a best practice to install Python modules with python -m pip install ?
Steve Wu
  • 109
  • 5
  • For `chmod` I think you just need to use of of the lines from [this answer](https://stackoverflow.com/a/8328529/14316282) and I believe it is best practice to use `python -m pip install`, that's what I always use at least. – Rolv Apneseth Jul 19 '21 at 11:31

0 Answers0