首先创建虚拟环境
conda create -n <your_env_name> python== #创建版本的python环境
activate <your_env_name> #进入该虚拟环境,否则使用pip等命令会调用到默认的全局pip
换源 安装环境
#换成 清华源 不然下载卡得慌…
conda config --add channels /anaconda/pkgs/free/
conda config --add channels /anaconda/pkgs/main/
conda config --set show_channel_urls yes
#要在此环境下安装ipython和jupyter,否则会默认调用全局的ipython和jupyter,但是全局的版本跟虚拟环境的版本不一样,所以jupyter Notebook中就看不到这个内核了。之前就是犯了这个错误,参考了这个 issue的回答 才解决。
conda install ipython #如果虚拟环境是python2.7那么就要安装版本,ipython6.0及以上的版本不支持python2.7
conda install jupyter #安装jupyter
conda install jupyterlab #安装jupyterlab, 二者选一即可
然后就可以愉快地使用新的环境的jupyter啦~注意要切换内核哟
jupyter #就可以调用啦 退出的时候关掉网页然后再命令行里面按crtl+z即可
deactive #别忘了退出虚拟环境吖
添加kernel
按照这个教程添加kernel到jupyter中
还可以修改jupyter notebook的默认文件夹
reference
通过ExecutionTime插件来对每个cell的运行计时
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable execute_time/ExecuteTime