user16890274
user16890274

Reputation:

Python: No module named 'numpy'

I tried to import numpy but I received a ModuleNotFoundError: No module named 'numpy' error. Someone told me it could be because I didn't have numpy installed, but I already did.

upon installing numpy I got Requirement already satisfied: numpy in ./opt/anaconda3/lib/python3.8/site-packages.

which python returns /Users/MacBook/opt/anaconda3/bin/python. I am new at this, but I'm guessing the reason I got that error was because the files aren't in the same place? If so, how do I move it to the right place?

side note: I have a similar issue with matplotlib and this is running on VS code if that helps. Also I use spyder and I don't get the numpy nor the matplotlib error over there, but the error seems to be on VS code

Upvotes: 0

Views: 2014

Answers (2)

xulgen
xulgen

Reputation: 16

Anaconda installs its own conda environment to run python. Probably VS Code can't access. Try this command;

python -mpip install numpy

If your python file named numpy.py, you can get this error too.

If doesn't work maybe you can try to change the environment to Anaconda environment. check this

Upvotes: 0

steveshapiro8855
steveshapiro8855

Reputation: 31

Try uninstalling numpy and re-installing. You also try re-install anaconda. I had this same issue and that fixed it.

Upvotes: 1

Related Questions