Search code examples
pythonnumpypython-3.6prettytable

Python Error: ModuleNotFoundError: No module named '<moduleName>'


I am trying to import several modules that I know for a fact that are installed, but I am getting the ModuleNotFoundError: No module named '' error.

$ sudo -H pip install numpy
    Requirement already satisfied: numpy in /usr/local/lib/python3.6/site-packages (1.18.1)
$ python3

Python 3.6.9 (default) 
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>> import PrettyTable
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PrettyTable'

Can you advise me on how to fix this problem?


Solution

  • Python3 and pip are most likely pointing to different versions of python. Try the following:

    sudo python3 -m pip install numpy
    

    This will use the pip command associated with the python3 environment.