如何在Mac OS X上查找所有python安装并卸载除本机OS X以外的所有安装 [英] How to find all python installations on mac os x and uninstall all but the native OS X installation

查看:194
本文介绍了如何在Mac OS X上查找所有python安装并卸载除本机OS X以外的所有安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MacBook上为不同的项目安装了几个版本,直到现在才意识到这是个错误.我已经使用自制软件安装了它,并通过python的网站(Python 2.7.8 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6 and later [2]))和其他我可能不记得的方法来安装了它.我正在运行10.9.4 OS X.

I have installed a few versions on my MacBook for different projects and have only now realized what a mistake that was. I have used homebrew to install it, installed it via python's website (Python 2.7.8 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6 and later [2])) and other ways I may not remember. I am running 10.9.4 OS X.

我想知道如何找到计算机上所有python安装程序的位置,并删除所有依赖于它们的包和软件包.希望从头开始,而无需重新安装操作系统.

I am wondering how I can find the location of all python installations on my computer and delete everything and packages that depend on them except the native one. I'd like to essentially start from scratch without reinstalling my OS.

此外,我想知道是否可以应用相同的方法来查找所有与pip相关的文件.

Also, I am wondering if I can apply the same method to find all pip related files.

更新 :

Update:

which -a python为我提供了每个可执行python的所有路径.有多个是正常的吗?

which -a python gives me all the paths to each executable python. Is it normal to have multiple ones?

╭─ishaantaylor@Ishaans-MacBook-Pro.local ~
╰─➤  which -a python
/usr/bin/python
/usr/bin/python
/usr/bin/python
/usr/bin/python
/usr/bin/python
/usr/bin//python
/usr/bin//python
/usr/bin/python

推荐答案

通常有很多python二进制文件.您可以使用以下命令在/usr/bin中查看哪个:

It's normal to have many python binaries. You can see which is which in /usr/bin with this command:

$ ls -l /usr/bin/python*

您将看到几个指向不同地方的链接. native python是那个,位于/System/Library/Frameworks/Python.framework/Versions/2.7/bin/中.请注意,对于OSX 10.9(以及至少在10.13之前的所有产品),这是python2,而不是python3.因此,您可以安全地删除所有其他版本.

You will see several links to different places. The native python is that one, which is in the /System/Library/Frameworks/Python.framework/Versions/2.7/bin/. Note that for OSX 10.9 (and for everything at least until 10.13) this is the python2, not python3. So you can safely remove all the other versions.

您还可以使用哪些其他版本?

What are the other versions which you may have?

  • 从官方网站 python.org 下载的内容.它位于/Library/Frameworks/Python.framework/Versions/中.您可以删除它.
  • Anaconda 分发默认位于/Users/your_user/anaconda3/中,但是您当然可以放在其他位置.但是,如果路径中包含anaconda,则为Anaconda发行版.您可以删除此文件夹.
  • homebrewport版本均在/opt/local/bin/中.使用$ ln -l /opt/local/bin/python*查看链接目标.消除此问题的最佳方法是使用内置命令,例如 uninstall .
  • 某些软件包可能位于~/Library/Python/中-来自pip.您可以安全地删除此文件夹的全部内容,以使干净" python.
  • 最后,在删除所有其他版本之后,请不要忘记删除断开的二进制链接,如果仍有的话.
  • Something downloaded from the official site python.org. It is located in /Library/Frameworks/Python.framework/Versions/. You can remove this.
  • Anaconda distribution is by default located in /Users/your_user/anaconda3/, but of course you may put in the other place. But if it contains anaconda in the path – it's Anaconda distribution. You may remove this folder.
  • Either homebrew or port versions are in /opt/local/bin/. See the link destination with $ ln -l /opt/local/bin/python*. The best way of removing this is to use built-in commands like uninstall.
  • Some packages might be in ~/Library/Python/ - that's from pip. You may safely remove the entire content of this folder in order to have a "clean" python.
  • Finally, after you removed all the other versions, do not forget to remove the broken links to binaries, if there are still any.

另请参见此答案.

这篇关于如何在Mac OS X上查找所有python安装并卸载除本机OS X以外的所有安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆