文章简介
注意:本文基于win系统conda环境,为本人遇到相关问题的解决办法,其他系统同理。前面是一些一般问题的解决(本人遇到的,供大家参考),后面是jupyter重装的一种方案(本人部署笔记)。如有错误和不足欢迎指出
1.nb_conda与python版本问题
nb_conda版本与python版本不匹配。nb_conda只支持python3.9以下版本。本人之前虚拟环境中低版本python安装有nb_conda,确实nb,但是在本人查看环境时造成了很大误导。之后低版本应该也不会再安装了。
如果要卸载nb_conda(一般也没必要卸载,只是本人采用的部署方案不一样,用不到它了)
conda uninstall nb_conda
2.运行notebook时报错,报错:提示jupyter和ipywidgets版本更新
这篇文章提供的方案很实用
# (base):
conda install -c conda-forge widgetsnbextension
# (env-name):
conda install -c conda-forge ipywidgets
如果确实要更新的话运行如下代码
conda update jupyter
3.jupyter notebook启动后没有找到虚拟环境内核kernal
#进入对应的虚拟环境,下载包
pip install --user ipykernel
#使用包,让该环境注册到notebook中
python -m ipykernel install --user --name=[env-name]
补充:网上也有人说这个方案会报错,需要进一步找原因,但本人运行没有问题。可能是因为我只有一个jupyter,安装在base环境下的原因
4.conda的一种jupyter配置方案
说明:在base环境中安装jupyter,在其他环境中注册jupyter内核,注册环境变量使用
4.1卸载(在所有安装有jupyter的环境中都适用,nb_conda如前文单独卸载)
pip uninstall -y jupyter
pip uninstall -y jupyter_core
pip uninstall -y jupyter-client
pip uninstall -y jupyter-console
pip uninstall -y notebook
pip uninstall -y qtconsole
pip uninstall -y nbconvert
pip uninstall -y nbformat
4.2base环境下安装
# 这里-c是指定从anaconda处下载jupyter包,但是可能不是最新版
conda install -c anaconda jupyter
# 不是的话更新一下
conda update jupyter
# 或者直接conda install jupyter,不过我没试过,原理上应该好用的
4.3进入虚拟环境配置notebook内核
pip install --user ipykernel
python -m ipykernel install --user --name=[env-name]
4.4注册jupyter进入环境变量
如果没有注册系统环境变量会导致其他环境下不能使用jupyter notebook命令,令人伤心