jupyter-notebook添加python虚拟环境

本文是在anaconda的环境下配置的,装好anaconda后,jupyter-notebook就自带装上了。我们在使用python的过程中往往需要使用虚拟环境,在终端下**虚拟环境很方便,但是在jupyter-notebook中需要进行一些配置方可使用。

首先,为需要在jupyter-notebook中使用的虚拟环境安装ipykernel

conda install -n tensorflow ipykernel
//tensorflow是我的虚拟环境

jupyter-notebook添加python虚拟环境jupyter-notebook添加python虚拟环境

其次,**tensorflow虚拟环境(source activate tensorflow),然后用如下命令生成ipykernel的配置文件(–name之后跟的是在jupyter-notebook中对应虚拟环境的kernel名称)

python -m ipykernel install --name tensorflow-notebook 
//其中,tensorflow 是我的虚拟环境

jupyter-notebook添加python虚拟环境

结果:

jupyter-notebook添加python虚拟环境