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

3
  • 1
    You probably have different python versions on your computer, you're running one and the module is installed in the other Commented Sep 12, 2021 at 5:42
  • Have you activate conda? conda activate base More over in VS Code you can select the environment. Can you check that too? Commented Sep 12, 2021 at 5: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? Commented Sep 12, 2021 at 6:06

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I uninstalled already and had it reinstalled but it still return error
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.