Mac OSx: ModuleNotFoundError: No module named 'numpy'

After I have reinstalled anaconda I can not import numpy anymore on Python3

import numpy as np
ModuleNotFoundError: No module named 'numpy'

I have tried

pip install numpy

I try to install it again I get:

pip install numpy
Requirement already satisfied: numpy in /anaconda3/lib/python3.7/site-packages (1.16.3)

enter image description here

3

3 Answers

This command worked for me

python3 -m pip install numpy

You are using a conda environment to run your program. So you should run:

conda install numpy

If you use IDE like Pycharm, it will be easy to install packages by a mouse click (Install packages).

You probably have multiple numpy versions installed on your system and need to manually delete the old one.

1) Open Terminal and run:

pip list

2) Remember or notate the numpy version from the list

3) Then run Python in Terminal or write and execute this code in your IDE:

import numpy
print(numpy)
print(numpy.__version__)

4) This should print two lines: numpy package location + numpy version like this:

<module 'numpy' from '/usr/local/lib/python2.7/site-packages/numpy/__init__.pyc'>
1.16.1

5) If the numpy version reported here is different then the one reported by pip list then go to the numpy package location printed above and delete that package folder

6) Try importing numpy now. If you previously installed it, it should work. If you didn't install it then go and install it now. After installation all should work fine.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like