Too many pythons on my Mac OS X Mountain Lion

醉酒当歌 提交于 2019-12-05 22:15:39

You actually have 5, yes 5, versions, not 8, not 8. And 4 of those 5 are part of the OS and should never be removed. So you only have 1 excess, not 7.

ls -l /System/Library/Frameworks/Python.framework/Versions/
total 8
drwxr-xr-x   6 root  wheel  204 Jun 20 16:23 2.3
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.5
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.6
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.7
lrwxr-xr-x   1 root  wheel    3 Jul 29 17:41 Current -> 2.7

That's 4. A symlink Current -> 2.7 is not another version, it's the same version again. These 4 all come with your system, and may be used by tools that are part of the system. You should not ever get rid of them, or anything else inside the /System directory (or the /usr/bin shortcuts that launch them).

Meanwhile, you have these in your path:

/Library/Frameworks/Python.framework/Versions/Current/bin:
/Library/Frameworks/Python.framework/Versions/2.7/bin
/Library/Frameworks/Python.framework/Versions/Current/bin

That's just three copies of the same version, most likely the official Python 2.7 from python.org. My guess is that you ran the old-style installer once, and then ran the newer installer once.

But it doesn't matter how they got there (unless it was through Homebrew, in which case just brew unlink python and you're done). You get rid of it by following the uninstall instructions at python.org, and then you will have only the minimal 4 again.

After a quick check, I can't find the page that used to have the simple uninstall instructions at python.org, but basically, it's this:

rm -rf /Library/Frameworks/Python.framework

You can then do an ls -l /usr/local/bin | grep Python.framework and rm everything that turns up. (You can automate that, but it's probably better to see exactly what you're deleting.)

You may also want to find what's adding the extra stuff to your PATH. Likely places to look are ~/.bash_profile (where the python.org installers do it), similar files like ~/.bashrc or ~/.profile (where others may have told you to put it), and possibly /etc/paths or /etc/paths.d (where you may have put it to make it work with GUI apps).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!