I am using Python 3.8 on a Ubuntu 20.04 computer. So far, I had no problem importing packages from either Spyder of Jupyter.
I have created a conda virtual environment called theory
using Python 3.6, as confirmed by running python --version
from within this conda environment.
conda list
reveals that numpy is installed:
numpy 1.19.4 pypi_0 pypi
Opening a Python interactive session from the terminal and importing numpy in there works like a charm. However, when trying to import numpy from within Spyder, I am getting a "Module Not Found" error:
ModuleNotFoundError: No module named 'numpy'
Here is what I tried to fix this issue:
- I tried uninstalling and reinstalling numpy using
pip install numpy
(andpip3 install numpy
). - I tried updating conda following the answer provided in this GitHub post:
conda update --prefix /home/sheldon/anaconda3 anaconda
. - I tried specifying the path to the numpy package in the PYTHONPATH manager directly in Spyder, pointing to /home/sheldon/anaconda3/envs/
What am I doing wrong here?
EDIT: I checked that Numpy 1.9.4. actually supports Python 3.6
EDIT: Just recreated a new Python 3.6 environment from scratch and I can import numpy just fine...
envs/theory
. Then close and re-open Spyder. The path to your envs folder depends upon your os, I think it is under your Anaconda folder. Note -- this worked for all my previous conda envs, but didn't work for my most recently created conda env, for some reason. For that, I had to actually install spyder-kernels package within the env itself, and run spyder from within that conda env (using conda command-line). Can't say I understand much, just thinking out loud. – fountainheadanaconda3/envs/theory/bin
but all of these made the kernel crash. I had to revert back to the default interpreter (i.e. the same as Spyder). – Sheldon