Custom Search

Tuesday, August 8, 2017

How to uninstall Python Virtualenv from IPython Jupyter Notebook

1)
List all kernelspec
$ jupyter kernelspec list
Available kernels:
  myenv1     /home/user/.local/share/jupyter/kernels/myenv1
  myenv3     /home/user/.local/share/jupyter/kernels/myenv3
  python2    /home/user/myenv3/share/jupyter/kernels/python2
  python3    /usr/local/share/jupyter/kernels/python3

2)
Uninstall  kernelspec
$ sudo ipython kernelspec uninstall myenv3


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.