MySQL-python in Leopard.

Python and mysqldb

Installing the python library for MySQL in Leopard can be a bit tricky. If you’re an easy_install lover, the first thing to try would be:

$ sudo easy_install MySQL-python

But the results you’ll obtain will be not very encouraging.

Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python
Reading http://sourceforge.net/projects/mysql-python/
Best match: MySQL-python 1.2.2
Downloading http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz
Processing MySQL-python-1.2.2.tar.gz
Running MySQL-python-1.2.2/setup.py -q bdist_egg –dist-dir /tmp/easy_install-07GTpt/MySQL-python-1.2.2/egg-dist-tmp-t78bko
In file included from /opt/local/include/mysql5/mysql/mysql.h:47,
from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
In file included from /opt/local/include/mysql5/mysql/mysql.h:47,
from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
lipo: can’t open input file: /var/tmp//cczla7iC.out (No such file or directory)
error: Setup script exited with error: command ‘gcc’ failed with exit status 1

But the solution is there. As you can see, the command talks about an error in line 40 for some file called _mysql.c. We’re going to get to that file and remove one line.

First we need to download the package. We will use easy_install, but later. So now grab your wget or your browser to here. And when you have the file, uncompress it (terminal or through finder).

$ wget http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz

$ tar xzf MySQL-python-1.2.2.tar.gz

Now go to the directory that has just been created and open the file _mysql.c. Go to the line number 38.

35 #include “my_config.h”
36 #endif
37 #ifndef uint
38 #define uint unsigned int
39 #endif
40 #include “mysql.h”

Delete line 38, save and install your modified egg from the parent directory with:

$ easy_install MySQL-python-1.2.2
Processing MySQL-python-1.2.2
Running setup.py -q bdist_egg –dist-dir /Users/alff/tmp/MySQL-python-1.2.2/egg-dist-tmp-S4uIM7
ld: warning in /opt/local/lib/mysql5/mysql/libmysqlclient_r.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libz.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libssl.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libcrypto.dylib, file is not of required architecture
zip_safe flag not set; analyzing archive contents…
Adding MySQL-python 1.2.2 to easy-install.pth file
.
Installed /Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg
Processing dependencies for MySQL-python==1.2.2
Finished processing dependencies for MySQL-python==1.2.2

The problem was that _mysql.c defined the type unit and that type is defined again when it includes the file mysql.h. We remove the duplicate, the compiler is happy :)

Edit: If you installed mysql5 with MacPorts, and you get the error EnvironmentError: mysql_config not found when installing the egg. Just add a link from mysql_config to mysql_config5.

# which mysql_config5
/opt/local/bin/mysql_config5
# cd /opt/local/bin/
# ln -s mysql_config5 mysql_config

Tags:, , , , , »
Comments (4) »

Late but still here

Desktop screenshot

It’s the first hour of the Saturday and I’m still awake listening to the rain beating on the floor of my alley.

It’s late but I’m still finishing some “job” tasks. This happens when you go commando in programming (but with underwear), and if everything goes well you´ll only make another 4 extra hours, but if something fails you´ll be doomed. A 7 instead of a four made me to stay until now connected (The good and the bad of the Virtual Private Networks).

As always I leave my Blog a bit abandoned. Some times it’s because the lack of free time, but other times it’s because I’m lazy. Not in the mood these days to do much.

I’m still in Athens and still working for that marvellous company who helps me to pay the bills every month. The good of working in a big IT company is that:

  • You learn how to move between multiple manager levels.
  • You can play the hot potato game with the problems. There is always someone to forward the email.
  • You improve your skills in how to solve problems quickly.
  • Your definition of dirty coding changes.
  • Yeah, it’s my first job here, so it’s experience for my résumé.
  • I have in the office 2×20″ screens, making a total resolution of 3200×1200 pixel.
  • You save the company with your skills.

The bad:

  • You learn how it feels to arrive home at 2:30am after all the day working.
  • You receive hot potatoes and you run out of addresses to forward them to.
  • You improve your skills to solve problems quickly and in a dirty way.
  • You forget about good coding.
  • You realize that your résumé needs the experience, not you.
  • It tooks 3 months to get a computer.
  • After you saved the company. You don’t see a part of the profit.

About friends and life. From time to time I meet the “International Pizza” to go for ouzo and food. The “International Pizza” is a mix of greeks and foreigners who meet to have good time :)

As objectives to accomplish:

  • To learn Greek. C’mon! One year here and I cannot speak it. It’s not so difficult.
  • To go to the gym. And also add an excuse to escape from the office.
  • To continue some personal projects/ideas. Not only talk about them when going for beers.

And from here send greetings to:

  • Sascha, Panos and the International Pizza.
  • Kat, her mac, and her 1001 stories. Life is long but I guess she lived twice or three times more experiences than anyone.
  • Nazgul2, from Palencia but working and living in another two different places.
  • Graci, and his amazing adventures in Belgium.
  • Alberto, and his never ending PhD problems.
  • Seattle and Andoni, or the two guys who got the job they were waiting for.
  • And you, who are reading this.

Note: Believe me if I tell you that I pressed the publish button like 5 times, and 5 times the post appeared in the front page. Then I leave, check the next day and It’s not there. Grrrrr.

Tags:, , , , , , »
Comments (3) »