0

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

  • 1
    You probably have different python versions on your computer, you're running one and the module is installed in the other – mozway Sep 12 '21 at 05:42
  • Have you activate conda? `conda activate base` More over in VS Code you can select the environment. Can you check that too? – Prayson W. Daniel Sep 12 '21 at 05:57
  • @mozway I figure that could be a possibility, but 1. how do I check the version on my computer vs the one on VS code, and 2. how do I get them to be the same version? –  Sep 12 '21 at 06:06

2 Answers2

1

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

  • I uninstalled already and had it reinstalled but it still return error –  Sep 12 '21 at 14:00
0

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

xulgen
  • 16
  • 1