Skip to content

Instantly share code, notes, and snippets.

@luflow
Forked from zeuxisoo/MAMP with Python-MySQLdb.txt
Last active October 5, 2015 16:54
Show Gist options
  • Save luflow/bf4fd36946f069ee22cf to your computer and use it in GitHub Desktop.
Save luflow/bf4fd36946f069ee22cf to your computer and use it in GitHub Desktop.
Mac OS X 10.10 Yosemity MAMP installation of MySQL-python
Last tested Oct 2015
OS X 10.10.5
MAMP 3.4
0. Get your MySQL Version: /Applications/MAMP/Library/bin/mysql --version
1. Goto http://downloads.mysql.com/archives/community/
2. Select Platform: "Mac OS X"
3. Download correct version with latests OS version (see step 0 - in my case 5.5.42)
Mac OS X 10.9 (x86, 64-bit), Compressed TAR Archive mysql-5.5.42-osx10.9-x86_64.tar.gz
The version for Mac OS X 10.9 also worked on my OS X 10.10
4. Untar it
5. Copy "include" folder into "/Applications/MAMP/Library"
6. Copy "lib/*" files into "/Applications/MAMP/Library/lib"
----
1. Goto https://pypi.python.org/pypi/MySQL-python
2. Download latest version (in my case https://pypi.python.org/pypi/MySQL-python/1.2.5)
3. unzip it (will be called "mysql-python" folder from now on)
----
0. cd into "mysql-python" folder
1. virtualenv --no-site-package test
2. cd test/bin
3. source activate
4. export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib
----
1. cd into "mysql-python" folder
2. vim setup_posix.py
3. search for line where mysql_config.path="mysql_config" is set
4. change the value to "/Applications/MAMP/Library/bin/mysql_config"
5. save and exit
6. python setup.py install
----
Use it:
1. cd to your project folder
2. change into your virtualenv with "workon PROJECTNAME" (asuming you created already one with mkvirtualenv PROJECTNAME)
3. pip install MySQL-python
READY!
----
TROUBLESHOOTING
If you get an Exception "Reason: image not found"
Set your environment variables:
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib
or even better:
sudo ln -s /Applications/MAMP/Library/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Have fun!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment