Search code examples
pythonnumpyanacondaspyder

Is there a way to have Spyder on Anaconda import numpy?


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


Solution

  • 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