Table of Contents Hide
Python throws modulenotfounderror: no module named ‘numpy’, in four conditions –
- When you have multiple versions of python installed and you installed numpy on one version but using different one for running your code.
- When Python directory is not listed in environment path variables.
- When you have multiple virtual environments like CygWin and you are mixing things up.
- Numpy is not installed.
The solution of this numpy modulenotfound error is to check all the 4 conditions.
If you are using Python3 then install numpy using this command –
python3 -m pip install numpy
or you can also use pip3 –
pip3 install numpy
for other python version use –
pip install numpy
Check Environment PATH
First check where your python is installed. It could be anywhere, but the most common locations are –
Python36 is Python version 3.6. Yours could be different so check that out. Also
akash is my user but yours will be different.
Now, after getting python location, you can check the environment path variable if its included there or not. This guide will help you in setting paths.
Reinstall Python and Numpy
You can always try the most reliable solution of reinstalling.
pip3 uninstall numpy pip3 install numpy
If you are running under virtual environments then make sure your different packages should also be inside the same environment. For example –
(venv) -> which python /Users/akash/venv/bin/python (venv) -> which ipython /usr/bin/ipython
Here python is in different environment and ipython in different. Make sure your code loads the libraries from your environment only.