Mac, Python 2.7, MySQL AND python-mysql
Published: april 19, 2011
I'm switching jobs (again!) and upgrading from a Dell-Hell-windows-machine to a Macbook Pro, and so far it has been both love and hate. Love because of the magsafe power connector and because of the Appstore, hate because of the non-existent application installation tool like apt-get for Debian/Ubuntu.
This is a howto of how to get a working django-environment up and running. This includes:
- Python 2.7
- Mysql 5.5
- Download and install python 2.7 from http://www.python.org/download/. I chose the 64-bit version and it works just fine, but if you are using some odd Python-lib you may want to use the 32-bit version.
- Install MySQL from http://dev.mysql.com/downloads/mysql/. I chose the .dmg-image 5.5 for 64-bit. Just to install, and remember to install MySQLStartup-thingie
- Install Mysql-python
Just get the latest version from http://sourceforge.net/projects/mysql-python/files/ (it's no top of the whole list) and extract.
Step into the extracted directory, edited the file calles setup_posix.py, and change the line
mysql_config.path = "mysql_config"
mysql_config.path = "/usr/local/mysql/bin/mysql_config"
Install by running:
python setup.py clean
python setup.py build
sudo python setup.py install
- Install pip
Since Python 2.7 added itself to your PATH you get access to all it's tools without having to do anything, so just:
- Install virtualenv, virtualenvwrapper
And now when pip installed, run:
pip install virtualenv virtualenvwrapper
- Fix path etc in .bash_profile
No you just have to add a few lines to some of your shell-related configs so everything ties together, I have chosen to edit ~/.bash_profile since I'm the only one who's gonna use this. So, open up ~/.bash_profile and the gist you find at
1 2 3 4 5 6 7 8 9 10# Location for MySQLexport DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH# Virtualenvwrapperexport WORKON_HOME=~/Envssource /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh# Adds mysql-toolsexport PATH=/usr/local/mysql/bin:$PATH
EDIT: As always with .bashrc, .bash_profile it's a mess to always get what you want, in my case I couldn't get PyCharm to get where mysql was located, so just move the line
to /etc/profile for example and this should be avalaible system wide instead.
In this howto I used many other howtos, and here are a list of some of them, thank you all!