简体   繁体   English

从Mac OS X El Capitan卸载Python 2.7

[英]Uninstall Python 2.7 from Mac OS X El Capitan

I want to completely reinstall Python 2 but none of the guides I have found allow me to uninstall it. 我想完全重新安装Python 2,但我发现的指南都没有允许我卸载它。 No matter what I do, python --version still returns 2.7.10, even after I run the Python 2.7.11 installer. 无论我做什么,即使在我运行Python 2.7.11安装程序之后, python --version仍然会返回2.7.10。 All the other guides on StackOverflow tell me to remove a bunch of files, but python is still there. StackOverflow上的所有其他指南告诉我删除一堆文件,但python仍然存在。

This may be a bit late, but for future searchers I'll post anyway: 这可能有点晚了,但对于未来的搜索者我还会发布:

I was looking to do the same. 我当时也想做同样的事情。 But I came across this paragraph at the Foundation ( Getting and uninstalling MacPython ) which convinced me to leave well alone and not uninstall it. 但是我在基金会( 获取和卸载MacPython )中遇到了这个段落,它说服我单独离开而不是卸载它。

The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. Apple提供的Python版本分别安装在/System/Library/Frameworks/Python.framework和/ usr / bin / python中。 You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. 您永远不应修改或删除这些内容,因为它们由Apple控制并由Apple或第三方软件使用。 Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do. 请记住,如果您选择从python.org安装较新的Python版本,那么您的计算机上将安装两个不同但功能强大的Python,因此您的路径和用法与您想要执行的操作一致非常重要。

Set your an alias to use the python version that you want to use from inside your .bashrc (or zsh if you use it). 设置别名以使用.bashrc要使用的python版本(如果使用它,则使用zsh)。

Like: alias python='/usr/bin/python3.4' 喜欢: alias python='/usr/bin/python3.4'

Agree with the accepted answer that uninstalling is a bad idea, but for those of you using HomeBrew to install your own Python, you don't need an alias as in @Mat Marsiglio's answer. 同意卸载是一个坏主意的公认答案,但是对于那些使用HomeBrew安装自己的Python的人来说,你不需要@Mat Marsiglio的答案中的别名。 Rather you can do what the HomeBrew installation suggestions: 相反,你可以做HomeBrew安装建议:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

This gives brew's python precedence over the built-in one at /usr/bin/python 这使得brew的python优先于/ usr / bin / python中的内置函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM