如何卸载所有python版本并使用OS X 10.10的默认系统版本? [英] How to uninstall all python versions and use the default system version of OS X 10.10?
问题描述
我正在寻找一种方法来清除OS X 10.10上所有版本的python,但Mac随附的默认版本除外.我该如何进行?
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?
目前,我有一些奇怪的行为.键入which -a python
时,得到以下输出:
Currently I've some weird behaviour. When typing which -a python
I get the following output:
/Users/harisfawad/anaconda/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
为什么在/System/Library/.../
中没有显示python的默认版本?我可以在Finder中找到该版本,所以我知道它不会被删除.
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.
此外,echo $PYTHONPATH
返回一个空行.
Also, echo $PYTHONPATH
returns an empty line.
我可以继续删除所有这些文件夹,并期望默认版本正确运行吗?
Can I just go ahead and delete all these folders and expect the default version to run correctly?
我在这里已经阅读过类似的问题 http://bugs.python.org/issue7107 但是我不确定这是否仍然适用于python版本2.7/3.4.
I've read a similar inquiry here http://bugs.python.org/issue7107 but I'm not sure if this is still applicable to python versions 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.
更新:在运行brew doctor
时,我得到了Warning: "config" scripts exist outside your system or Homebrew directories.
,它继续列出了/.../anaconda/bin
和/Library/.../bin
中的配置"文件.
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
.
UPDATE2:我已经成功回到OS X中包含的默认python版本.所有上述python版本都移到了回收站,但/usr/bin/python
除外.谢谢@rhashimoto和@PadraicCunningham!
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!
推荐答案
文件/usr/bin/python
(和/usr/bin/pythonw
,这是指向同一文件的硬链接)实际上是一个启动程序,它调用Python的默认版本来自/System/Library/Frameworks/Python.framework/Versions
.您可以选择版本 (在Yosemite中为2.6和2.7),启动器使用defaults
命令或VERSIONER_PYTHON_VERSION
环境变量调用.
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/python2.6
或/usr/bin/python2.7
,它们是/System/Library/Frameworks/Python.framework/Versions
的符号链接.
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
.
您应该可以从路径中删除列出的所有其他Python实现,包括/Library/Frameworks/Python.framework/Versions/2.7/bin/python
(不确定如何获得该实现).在永久删除它们之前,将它们移到某个位置(例如您的回收站文件夹)以测试您的更改仍然是明智的选择.
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版本并使用OS X 10.10的默认系统版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!