Anaconda创建新虚拟环境并创建jupyter notebook相应的kernel ( 含多版本python )

首先创建虚拟环境

conda create -n <your_env_name> python==x.x  #创建x.x版本的python环境
activate <your_env_name>   #进入该虚拟环境,否则使用pip等命令会调用到默认的全局pip

换源 安装环境

#换成 清华源 不然下载卡得慌…
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes


#要在此环境下安装ipython和jupyter,否则会默认调用全局的ipython和jupyter,但是全局的版本跟虚拟环境的版本不一样,所以jupyter Notebook中就看不到这个内核了。之前就是犯了这个错误,参考了这个 issue的回答 才解决。
conda install ipython   #如果虚拟环境是python2.7那么就要安装5.x版本,ipython6.0及以上的版本不支持python2.7
conda install jupyter   #安装jupyter

然后就可以愉快地使用新的环境的jupyter啦~注意要切换内核哟

jupyter    #就可以调用啦 退出的时候关掉网页然后再命令行里面按crtl+z即可
deactive   #别忘了退出虚拟环境吖

还可以修改jupyter notebook的默认文件夹

详见https://blog.csdn.net/u014552678/article/details/62046638

猜你喜欢

转载自blog.csdn.net/Hesy_H/article/details/84257025