Reputation: 483
I have installed Jupyter notebook and use it with a virtualenv, I already have installed some packages in python but when I run in Jupyter notebook for example import numpy as np, I have a issue, module not found, there are a way to connect all of my python installed packages with Jupyter notebook?
Thanks!
Upvotes: 0
Views: 2980
Reputation: 369
To access the packages within your environment you have to register the kernel with jupyter.
pip install ipykernel
python -m ipykernel install --user --name=[name of your environment]
jupyter notebook
As below:
Upvotes: 8
Reputation: 61
If you installed your packages in python and launched your jupyter notebook from your virtualenv, you cannot import those installed packages because virtualenv created an isolated Python environment. You can read about virtualenv here.
There are two ways to resolve your problem:
Launch jupyter notebook without virtualenv (simply type jupyter notebook
in your terminal / command prompt)
Install those packages inside your virtual environment.
Upvotes: 0
Reputation: 140
The jupyter notebook
command may not be referencing to the jupyter installation in the virutal environment you are using. This is why even though you might have installed packages in your environment, jupyter is unable to import them because it is looking at a different place.
You could try to set up a different kernel for your environment, but I find that task to be tedious and after a while it becomes hard to keep track of your kernels.
The best way would be to start jupyter notebook with the python environment where all your modules are installed. To do this, activate your virtual environment, and then do:
python -m jupyter notebook
This will open Jupyter with the jupyter installed in the place where your python
is pointing to and it will have the packages installed there!
Upvotes: 1
Reputation: 1488
There are two things to consider:
If you perform those actions correctly, then the error should go away.
Hope this help!
Upvotes: 0