彻底卸载uninstall jupyter notebook不完全与"The jupyter" distribution was not found问题

在使用 pip uninstall jupyter 或 conda uninstall jupyter 后,经常会发现jupyter notebook仍未被完全卸载,原因是pip在uninstall jupyter时只卸载了jupyter的部分包。

完全卸载jupyter notebook可采用:

pip install pip-autoremove
pip-auto remove jupyter -y

即可完整删除jupyter

它实际上删除了以下各相关的库,如果其中有其他库所依赖的库,可以手动卸载不需要的。

pip uninstall jupyter
pip uninstall jupyter_core
pip uninstall jupyter-client
pip uninstall jupyter-console
pip uninstall notebook
pip uninstall qtconsole
pip uninstall nbconvert
pip uninstall nbformat

自行注意切换pip/pip3。

 

如果在卸载jupyter时报错,"The jupyter" distribution was not found,但在命令行中输入jupyter仍然存在的情况,是因为系统中装了多个jupyter notebook导致的。这个问题似乎比较罕见,csdn/stack overflow上也没几个讨论的,今天恰好遇到这个error并解决了,在此分享一下解决办法。

问题的关键在于可能在多个python/pip环境下安装了多个版本的jupyter,在执行pip uninstall的时候,卸载的只有本版本pip安装的jupyter而已。使用pip的版本可以用 which pip 查看,可以用which -a pip查看安装于本机的所有pip。

因此,我们只要用which -a jupyter就可以看到本机安装的所有版本的jupyter,然后对应一一卸载。大多数情况下jupyter和pip的文件路径是一样的,因此使用该目录的pip对其卸载即可。
如,假设我们看到一个jupyter的path是/usr/local/bin/jupyter,就可以使用下方命令对其进行卸载:

/usr/local/bin/pip uninstall jupyter

当然你可以ls该目录查看所有jupyter相关的库,然后使用上方的手动卸载方式一一卸载。

当然有可能你安装的是snap下的jupyter,如果你看到有一个jupyter是存在于类似于/usr/bin/snap目录下的话。
对于snap安装的jupyter,使用snap remove jupyter即可卸载。

删掉所有版本的jupyter,jupyter notebook就被彻底删除了,接下来使用pip install jupyter即可重新安装,当然建议在装之前,pip install -U pip 更新一下pip

最后,说一下这个error可能的原因,个人分析是在anaconda环境下安装jupyter notebook时,使用sudo apt install jupyter-core或sudo snap install jupyter导致的,因此注意在anaconda下,尽可能使用conda install jupyter或pip install jupyter来进行jupyter notebook的安装。

 

发布了9 篇原创文章 · 获赞 2 · 访问量 1354
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章