One thing you should not do is try to remove or change any of the Apple-supplied python files or links: they are in /usr/bin
and /System/Frameworks/Library/Python.framework
. These are part of OS X and managed by Apple. It is fine to clean up any unnecessary packages you have installed for that Python. They are in /Library/Python
. If you installed a python.org Python and want to remove it, most of the files are in /Library/Frameworks/Python.framework
. See here for complete instructions on how to remove them. And anything you installed into /usr/local
is fair game.
Using virtualenv
s is a fine idea but it's slightly less important on OS X where the concept of framework builds makes it easier to support multiple Python versions than on some other platforms.
The bigger issue, especially trying to use MySQL with Python, is getting all of the necessary non-Python libraries installed and built properly which is non-trivial given the variety of options available on OS X. For instance, depending on which Python instance and which OS X level running, you may need 32-bit or 64-bit or, possibly, both versions of things like the MySQL client libraries and the MySQLdb adapter. For that reason, I highly recommend using a complete solution from MacPorts. That way you have a good chance of getting all the right components built compatibly - and easily.
If necessary, install the base MacPorts as described on the MacPorts website then:
$ sudo port selfupdate
$ sudo port py26-mysql
and that will pull in and build everything you need and make it available in /opt/local/bin
. There are also plenty of other ports available, for instance:
$ sudo port py26-virtualenv