Skip to content

Instantly share code, notes, and snippets.

@AhmedKammorah
Created September 14, 2013 18:10
Show Gist options
  • Save AhmedKammorah/6564218 to your computer and use it in GitHub Desktop.
Save AhmedKammorah/6564218 to your computer and use it in GitHub Desktop.
install Mysql python on mac and XAMMP
Installing MySQL-python on Snow Leopard using XAMPP MySQL
January 5, 2012
it starts when i try to do a Django setup. when i try to do manage.py syncdb, it says :
No Module named MySQLdb
ok, so it turns out that my mac doesn’t have mysql-python module installed yet. after i try struggle to install it, it turns out to be quite tricky. this is what i came up with. hopefully it helps others.
first of all, you will need the module itself. download from here :
http://sourceforge.net/projects/mysql-python/files/latest/download
(from this point forward i assume you have xcode installed. install xcode from your osx installation disk if you hadn’t done it yet.)
extract the package
cd into the folder (MySQL-python-1.2.3)
edit site.cfg, change mysql_config into your mysql_config path
(for XAMPP mysql the path will be “/Applications/XAMPP/xamppfiles/bin/mysql_config” )
1
2
3
4
# The path to mysql_config.
# Only use this if mysql_config is not on your PATH,
# or you have some weird setup that requires it.
mysql_config = /Applications/XAMPP/xamppfiles/bin/mysql_config
this is when it gets tricky, it turns out that XAMPP mysql lacks of mysql lib that was included in the standard mysql install. so download mysql server package that match your mysql version (in my case, the XAMPP use MySQL 5.1.44). and to make it even trickier, my XAMPP use 32bit version of MySQL where my Python runs on 64bit (more on that later), so get the 32bit version here :
http://dev.mysql.com/downloads/mysql/5.1.html
after it complete, extract the packages, and copy the “include” folder into /Applications/XAMPP/xamppfiles/ so it will be /Applications/XAMPP/xamppfiles/include
then run :
1
2
python setup.py build
python setup.py install
as i mention before, my python run on 64bit, so i need to set it to run on 32bit mode :
1
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
if all goes well, you can test the new module in the shell by typing :
>>> import MySQLdb
>>> MySQLdb.apilevel
'2.0'
well thats not too hard isn’t it? note to myself, plan for XAMPP upgrade to 64bit version, or maybe use MAMP instead.
ref :http://andhikalegawa.wordpress.com/2012/01/05/installing-mysql-python-on-snow-leopard-using-xampp-mysql/
http://sourceforge.net/projects/mysql-python/?source=dlp
-based on XAMMP install
-and mysql-python package
- configer it to connect with XAMMP MYsql
- and add Include folder from MYSQL package to XAMMP mysql
-and run mysql-python package install
- python setup.py build
- python setup.py install
// mysql-python location
/Users/ahmedkammorah/Desktop/Python WorkSpace/MySQL-python-1.2.4b4
sudo python setup.py build
sudo python setup.py install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment