Reputation: 5013
When I do
import sys
sys.executable
I get '/usr/local/opt/python/bin/python2.7'
in my ordinary python shell and '/usr/bin/python'
in IPython or my jupyter notebook. I would like to force my jupyter notebook to use this same python that the shell is using. I have installed many modules and would like to be able to use the same ones in jupyter than I am using already in the shell. How can I do this?
Upvotes: 2
Views: 1551
Reputation: 1417
I had the same problem when using jupyter from a virtualenv.
In my case I had two kernels named python3. Doing a jupyter kernelspec list
it reported only one kernel named python3 that pointed to an incorrect binary. I removed it using jupyter kernelpec remove python3
and magically appeared the correct one pointing to my activated virtualenv.
If you need to reinstall the kernel then, from the bin directory of the virtualenv you can do,
./python -m pip install ipykernel
sudo ./python -m ipykernel install
Upvotes: 0
Reputation: 40390
The simplest way is to install IPython and Jupyter with the Python you want them to use. You can do this using pip:
path/to/python -m pip install jupyter
You could alternatively set up the IPython kernel to run with your desired Python without reinstalling the notebook. See the docs on installing kernels. This is more complicated than just installing everything again, though.
Upvotes: 3