如何正确卸载python jupyter?

时间:2016-09-22 03:42:49

标签: python ipython jupyter jupyter-notebook

我在 Mac OSX 上安装了jupyter python3.5,但我想要python2.7版本。所以,我基本上需要卸载3.5版本,然后重新安装2.7版本。

但由于某种原因我无法卸载3.5版本。我尝试了sudo python3 -m pip uninstall jupyter,您可以看到以下结果:

✔  ~/current/directory  
20:08 $ which jupyter
/Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
✔  ~/current/directory  
20:08 $ sudo python3 -m pip uninstall jupyter
The directory '/Users/<username>/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Cannot uninstall requirement jupyter, not installed
The directory '/Users/<username>/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
✘-1  ~/current/directory  
20:09 $ which jupyter
/Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter

...正如您在上面所看到的,which jupyter命令仍然返回一个有效路径,而不仅仅是那个。我仍然可以从命令行启动jupyter notebook,它会打开一个笔记本。

如何正确删除现有版本的jupyter?或者,如果有人知道如何将python2内核添加到我现有的jupyter,那也没关系。这可能吗?

我能想到的只是手动杀死/Library/Frameworks/Python.framework/Versions/3.5/bin/内的文件和子文件夹,但这似乎不必要地残酷?

5 个答案:

答案 0 :(得分:3)

home文件夹中删除~/AnacondaProjects。之后,从您的bash个人资料export中移除Anaconda environment variable ~/.bashrc

答案 1 :(得分:2)

这里的答案解决了我的问题:https://stackoverflow.com/a/42277762/8057434

我只想总结一下该怎么做。 在终端中运行conda uninstall notebook nbconvert nbformat ipykernel ipywidgets qtconsole traitlets tornado jupyter_* ipython_genutils jinja2 -y。 如果您不使用anaconda,则可以使用pip uninstall代替conda uninstall

答案 2 :(得分:1)

使用pip3代替pip

pip3 uninstall jupyter 

只要使用正确的pip版本,就可以在同一台计算机上安装python 2和python 3

答案 3 :(得分:0)

  

我在Mac OSX上安装了python3.5的jupyter,但是我想要python2.7版本。

Anaconda是安装特定项目所需的python软件的好方法。

  1. https://www.continuum.io/downloads#macos
  2. 下载
  3. 如上所述,bash Anaconda2-4.3.1-MacOSX-x86_64.sh(在您的情况下为2.7版本)
  4. 转到已安装的目录并键入source bin/activate
  5. 这将创建一个命令行环境,它具有适当级别的库等。在内部,您可以使用f.ex安装更多数据。 conda install numpy。要修复版本,请使用conda install numpy=1.10

答案 4 :(得分:0)

你应该单独卸载jupyter-core,jupyter-console,jupyter-client。删除它们之后,这些都没有找到名为jupyter的包。