How to install mysql-python on Apple OS X Leopard
How to solve “Setup script exited with error: command ‘gcc’ failed with exit status 1″ on a Macbook Pro running Apple OS X Leopard 10.5.5 when installing mysql-python.
When I tried to build and install mysql-python, on my Macbook Pro running Apple OS X Leopard 10.5.5, I encountered a few problems (Setup script exited with error: command ‘gcc’ failed with exit status 1). But thanks to Google and the Python community, there were no problems that couldn’t be fixed.
Step 1 – Download and extract mysql-python
Let’s take it from the top. First you need to download mysql-python from the Sourceforge project page and extract the files.
Step 2 – Locate and edit _mysql.c
Locate the _mysql.c file in your mysql-python directory, open it up and remove the following three rows around row 35.
#ifndef uint #define uint unsigned int #endif
Still in _mysql.c, you should change the following two rows around row 480.
uint port = MYSQL_PORT; uint client_flag = 0;
Change those two rows to:
unsigned int port = MYSQL_PORT; unsigned int client_flag = 0;
Step 3 – Fix the mysql_config location (not always necessary)
You might need to open up the site.cfg file in your mysql-python directory and change the path to your mysql_config.
#mysql_config = /path to your mysql_config
Step 4 – Open up your terminal
You will need to create a symbolic link between /usr/local/mysql/lib and /usr/local/mysql/lib/mysql. Open up your terminal and do the following.
$ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
Step 4 – Rebuild and install
All done! You should be able to build and install mysql-python now. With your terminal in the mysql-python directory you should do the following.
$ sudo python setup.py build $ sudo python setup.py install
Projects
- Accordion (jQuery)
- Airport (jQuery)
- Chat
- Defaultvalue (jQuery)
- Elastic (jQuery)
- Highlight (jQuery)
- Keycan
- Lazy (jQuery)
- Limit (jQuery)
- Password Strength (jQuery)
- Show Password (jQuery)
- Tabify (jQuery)
- Valid8 (jQuery)
Latest posts
- July 8th, 2009 Why are we typing passwords twice?
- July 5th, 2009 Don’t stop password masking; let the user decide
- June 1st, 2009 You can’t validate email addresses with regular expressions
- May 20th, 2009 Konami Code: Why so verbose, when you can make it in 140 characters?
- May 18th, 2009 Let your users know if Firebug slows down your web page.