Using a virtualenv in an IPython notebook

创建虚拟环境

$ python -m venv projectname

进入虚拟环境

$ source projectname/bin/activate

安装 kernel

(venv) $ pip install ipykernel

创建 kernel

(venv) $ ipython kernel install --user --name=projectname

使用 conda 安装 kernel

conda install ipykernel

conda env 下

python -m ipykernel install --user --name myenv 

参考

https://anbasile.github.io/programming/2017/06/25/jupyter-venv/
https://ipython.readthedocs.io/en/stable/install/kernel_install.html