简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM