Reputation: 9109
I start my jupyter
notebook with python2
as:
jupyter notebook nameofnotebook
Then I want to import library like this:
import scipy
But I have an error telling that there is no such library.
So I execute in the notebook
cell:
!pip2 install scipy
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages
How to install package correctly to jupyter kernel?
Upvotes: 11
Views: 46835
Reputation: 23064
You can run pip from python.
import pip
pip.main(['install', 'scipy'])
If you are using the system python, and running jupyter in a process that doesn't have permission to install global packages, you can use the --user
flag to install a module for the current user only.
pip.main(['install', '--user', 'scipy'])
Upvotes: 2
Reputation: 23484
@håken-lid is right. There are probably several versions of python. So to install your package to python where your jupyter
is located:
$ which jupyter
/YOURPATH/bin/jupyter
$ /YOURPATH/bin/pip install scipy
This will do for Python 2.x
For Python 3.x pip3
will be in /YOURPATH/bin
instead of single pip
Upvotes: 5