如何卸载所有python版本并使用OS X 10.10的默认系统版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30844746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to uninstall all python versions and use the default system version of OS X 10.10?
提问by harisf
I'm looking for a way to cleanly uninstall all versions of python on OS X 10.10 except the default version that followed with the Mac. How do I proceed?
我正在寻找一种方法来干净地卸载 OS X 10.10 上所有版本的 python,除了 Mac 的默认版本。我该如何进行?
Currently I've some weird behaviour. When typing which -a python
I get the following output:
目前我有一些奇怪的行为。键入时,which -a python
我得到以下输出:
/Users/harisfawad/anaconda/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
Why doesn't the default version of python in /System/Library/.../
show up here? I can locate that version in Finder, so I know that it isn't deleted.
为什么这里没有显示默认版本的python /System/Library/.../
?我可以在 Finder 中找到那个版本,所以我知道它没有被删除。
Also, echo $PYTHONPATH
returns an empty line.
此外,echo $PYTHONPATH
返回一个空行。
Can I just go ahead and delete all these folders and expect the default version to run correctly?
我可以继续删除所有这些文件夹并期望默认版本正常运行吗?
I've read a similar inquiry here http://bugs.python.org/issue7107but I'm not sure if this is still applicable to python versions 2.7/3.4.
我在这里阅读了类似的查询http://bugs.python.org/issue7107,但我不确定这是否仍然适用于 python 版本 2.7/3.4。
This is also a similar question How to uninstall Python 2.7 on a Mac OS X 10.6.4?But again, I don't want to be careless and do the uninstalling before making sure that the system provided version works.
这也是一个类似的问题如何在 Mac OS X 10.6.4 上卸载 Python 2.7?但同样,我不想粗心并在确保系统提供的版本有效之前进行卸载。
UPDATE:When running brew doctor
I get this Warning: "config" scripts exist outside your system or Homebrew directories.
And it goes on listing the "config" files in /.../anaconda/bin
and in /Library/.../bin
.
更新:运行时brew doctor
我得到了这个Warning: "config" scripts exist outside your system or Homebrew directories.
并且它继续/.../anaconda/bin
在/Library/.../bin
.
UPDATE2:I've successfully gone back to the default version of python that was included in OS X. All the above versions of python where moved to trash, except /usr/bin/python
. Thanks, @rhashimoto and @PadraicCunningham!
UPDATE2:我已经成功返回到 OS X 中包含的默认 python 版本。所有上述 python 版本都移到了垃圾箱,除了/usr/bin/python
. 谢谢@rhashimoto 和@PadraicCunningham!
采纳答案by rhashimoto
The file /usr/bin/python
(and /usr/bin/pythonw
, which is a hard link to the same file) is actually a launcher program that invokes the default version of Python from /System/Library/Frameworks/Python.framework/Versions
. You can select the version(2.6 and 2.7 in Yosemite) the launcher invokes using either the defaults
command or the VERSIONER_PYTHON_VERSION
environment variable.
该文件/usr/bin/python
(和/usr/bin/pythonw
,它是指向同一文件的硬链接)实际上是一个启动程序,它从/System/Library/Frameworks/Python.framework/Versions
. 您可以使用命令或环境变量选择启动器调用的版本(Yosemite 中的 2.6 和 2.7)。defaults
VERSIONER_PYTHON_VERSION
If you want to run a specific version manually, you can invoke /usr/bin/python2.6
or /usr/bin/python2.7
, which are symbolic links into /System/Library/Frameworks/Python.framework/Versions
.
如果要手动运行特定版本,可以调用/usr/bin/python2.6
或/usr/bin/python2.7
,它们是/System/Library/Frameworks/Python.framework/Versions
.
You should be fine removing all other Python implementations you list from your path, including /Library/Frameworks/Python.framework/Versions/2.7/bin/python
(not sure how you got that one). It would still be wise to move them somewhere (e.g. your trash folder) to test your change before deleting them permanently.
您应该可以从路径中删除您列出的所有其他 Python 实现,包括/Library/Frameworks/Python.framework/Versions/2.7/bin/python
(不确定您是如何获得该实现的)。在永久删除它们之前将它们移动到某个地方(例如您的垃圾文件夹)以测试您的更改仍然是明智的。