How do I uninstall Python 2.5?
I recently upgraded to Mac OS 开发者_JS百科10.6 and didn't realise that it shipped with Python 2.6. I installed Python 2.5.4 and now it is the default Python installation. Can I uninstall Python 2.5.4 and keep 2.6?
While there is no uninstaller for the python.org OS X python installers (because they use the standard Apple installer mechanism which does not provide an uninstaller by default), it is not difficult to remove. I've documented the full process here but keep in mind that it doesn't hurt to have multiple python instances installed on OS X.
The key to managing it all is understanding where each instance is installed and how to manage your shell $PATH
search order. By default, the python.org installers modify your .bash_profile
(or .profile
) shell initialization file to add the python framework bin
directory at the front of your $PATH
, that is, before /usr/bin
where the Apple-supplied python
command is found. You'll probably find the unmodified version saved as .bash_profile.pysave
. Do a diff
first to make sure there aren't any other changes and then just mv
it back:
$ cd ~
$ diff .bash_profile{,.pysave}
12,16d11
<
< # Setting PATH for MacPython 2.5
< # The orginal version is saved in .bash_profile.pysave
< PATH="/Library/Frameworks/Python.framework/Versions/2.5/bin:${PATH}"
< export PATH
$ mv .bash_profile.pysave .bash_profile
Start up a new terminal session and verify that python
is again python2.6
. (This assumes your default login shell is bash
.)
If you want, you can then follow the instructions in the link above to actually remove all traces of the extra python. Note, do not attempt to remove the Apple-installed default python files in /usr/bin
and /System/Library/Frameworks
.
Use the uninstall utility of the same package manager you used to install it.
As a sidenote, you can just modify the PATH not to point to the 2.5.4 installation by default, and both can live happily side-by-side.
Not only path but also link to python
as it is now resolved as python2.5, not python2.6.
精彩评论