简体   繁体   中英

Problem importing (and installing) NumPy in Jupyter Notebook

I am having major trouble right now trying to use numpy in my jupyter notebook.

When I first tried to simply "import numpy" , it came back with the error: "ModuleNotFoundError: No module named 'numpy'"

I then read somewhere that I probably needed to install numpy.

So I did this: "import sys.conda install --yes --prefix {sys.prefix} numpy"

to which it came back saying: "EnvironmentLocationNotFound: Not a conda environment"

Now when it comes to understanding environments or packages or ANYTHING along those lines, I just have no idea what I'm doing. I am in a very beginner course and just following along.

I wish I could understand all of this environment and versioning stuff.

I have no idea where to go from here.

Any insight here would be GREATLY appreciated!!

Edit: I am in fact using Anaconda to launch Jupyter Notebook. Not sure if that means anything to your understanding of my problem or a potential solution.

Mark

For an easy to use graphical user interface to install Python libraries and manage environments, I would recommend Anaconda . It is well integrated with IPython and Jupyter Notebook in particular.

You could try the line bellow, at the notebook:

!pip install numpy

Or you could open up a terminal inside the jupyter notebook and install there, with:

pip install numpy

Another option is to install python3.7 from the anaconda website:

https://www.anaconda.com/distribution/

With anaconda a lot of packages come together when you install it. It's better for beginners. Good luck!

In my case, inside Jupyter notebook, you need to change Kernel (Anaconda environment). I thought you changed environment using conda activate myEnv , but when launching Jupyter, it defaults to the root environment. I hope this is in fact true- I am a noob in Anaconda.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM