简体   繁体   中英

How do I uninstall Python 2.5?

I recently upgraded to Mac OS 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.

现在不仅解析路径,而且链接到python因为它现在解析为python2.5,而不是python2.6。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM