如何在jupyter notebook中切换虚拟环境

如何在jupyter notebook中切换虚拟环境

    • 在base环境中安装nb_conda_kernels
    • 激活要切换的虚拟环境
    • 在激活的环境中安装ipykernel
    • 最后正常快捷启动jupyter notebook

在base环境中安装nb_conda_kernels

conda install nb_conda_kernels 

注意这个包只能用conda 安装,如果安装不下来,去搜索离线安装,解压之后放在base环境中的lib/site-packages下。

激活要切换的虚拟环境

conda activate tensorflow

这里名字根据自己环境名字切换

在激活的环境中安装ipykernel

pip install ipykernel

python -m ipykernel install --user --name tensorflow --display-name "Python (tensorflow)"注册环境

在当前环境中注册你的kernel,注册好之后如下图。

在这里插入图片描述

最后正常快捷启动jupyter notebook

选择自己喜欢的启动方式,cmd,开始菜单等等,也应为默认启动的是base环境,进去之后就可以在kernel中看到如图所示自己的其他虚拟环境,如果需要添加新的环境,在新的环境中安装ipykernel并且注册就好了。
如何在jupyter notebook中切换虚拟环境_第1张图片

你可能感兴趣的:(python,pytorch)