Custom Search

Tuesday, August 8, 2017

How to add Python virtualenv to IPython Jupyter notebook

1)
Install jupyter
$pip install -U jupyter

2)
Create virtual environment
$virtualenv myenv1

3)
Activate virtual environment
$source myenv1/bin/activate

4)
Install ipykernel in virtual environment
$ pip install ipykernel

5)
Add python and ipykernel in the virtual environment to jupyter notebook
$ python -m ipykernel install --user --name=myenv1

You should now be able to see your (virtualenv) kernel in the IPython
notebook menu: Kernel -> Change kernel and be able so switch to it.

5 comments:

  1. Great instruction now on my macOS I can import tensorflow in virtualenv jupyter notebook. Thank you!

    ReplyDelete
  2. This is exactly the tutorial I needed! I've been struggling to get my virtualenv to show up in Jupyter notebook, and your step-by-step instructions with the actual commands made it work perfectly on my first try. The ipykernel installation step is something I always forget. For working professionals who can't commit to weekday schedules, I've noticed that azure 104 weekend batches in electronic city are becoming quite popular for upskilling. Your blog continues to be a lifesaver for Python developers!

    ReplyDelete