I updated to Mountain Lion not long ago, and having used python previously, I now have 8 (yes, 8) versions of python installed on my computer.
$ 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
I would love to erase all of them and clean everything up, and I prefer to set all paths to the system python that comes with Mountain Lion. My goal is simplicity and cleanliness. I have been trying to do this for literally almost six months, off and on... there are a multitude of "solutions" and scripts available on the web for this problem, and none of them fully work or are even understandable. Can anyone tell me how to get these unwanted Python versions off of my Mac, or at least how to set my Mac so that everything goes nicely into the Mac system version of python. I don't have too many old Python files I particularly need to use, but I've noticed that I have trouble installing Python stuff and running .py scripts because the paths are all mixed up or something to that effect.
Also, I get this:
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/mysql/bin
...kind of scary-looking.
Thanks for your help. I am familiar with UNIX shell scripting and have a mid-level understanding of system admin stuff... but not advanced. I am a programmer in R so I know how to program and all of that. Appreciate any suggestions!
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).
来源:https://stackoverflow.com/questions/13654756/too-many-pythons-on-my-mac-os-x-mountain-lion