0
votes

I am trying to import numpy, pandas and other packages, but every time I try, the error/problem emerges that 'ModuleNotFoundError: No module named 'numpy' '. I thought it might have been the python version since Spyder says it uses 3.8.2 python and I was on 3.8.8 per 'python -V'. Upon switching, it indicated, 'Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.8/site-packages (1.20.3)' and I still can't import numpy in Spyder.

  • Spyder version: 4.2.5 None
  • Python version: 3.8.2 64-bit
  • Qt version: 5.9.7
  • PyQt5 version: 5.9.2
  • Operating System: Darwin 19.6.0

Terminal:

(base) readinger:~ neuro$ python -V
Python 3.8.2
(base) readinger:~ neuro$ 
(base) readinger:~ neuro$ 
(base) readinger:~ neuro$ pip install numpy
Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.8/site-packages (1.20.3)
(base) readinger:~ neuro$ 

Spyder on Anaconda:

runcell(0, '/Users/uju/untitled0.py')
Traceback (most recent call last):

  File "/Users/uju/untitled0.py", line 9, in <module>
    import numpy as np

ModuleNotFoundError: No module named 'numpy

enter image description here

enter image description here

1
Did you run spyder from the same environment?Mohammad
What do you mean? I ran Spyder from Anaconda Navigator and I clicked on 'python' --> 'about Spyder' and it gave the above information, which includes 'Python version: 3.8.2 64-bit'Daniel
In that case, you can open anaconda terminal and try to install the required packages or in anaconda navigator go to environments and look for the package you want to install.Mohammad
You mean in the above photo? it has 'numpydoc', but i don't think that's the same as 'numpy'. When I search for 'numpy', only 'numpydoc' shows up.Daniel
yes that's it. You are looking at the installed packages which means numpy is not installed yet. click on the dropdown and change it to All and search again for numpy.Mohammad

1 Answers

0
votes

The main problem is caused by you installing numpy on the terminal and not on Anaconda.

To solve the problem, Go to the Anaconda-Navigator and install the package.

Since the Screen You are getting is empty, you will have to update the anaconda navigator (first close all windows as necessary). In the command line type:

conda deactivate
conda update anaconda-navigator

This should update the navigator and allow you to install normally.

Alternatively, you can just install numpy from anaconda in the terminal:

conda install numpy