installing MySQLdb on Ubuntu (mysql-python)

23 January 2010

MySQLdb is the python support bindings for MySQL.  Not that the name would lead you to beleive that.

Its sourceforge page calls it http://sourceforge.net/projects/mysql-python/ which makes more sense.

you need setuptools, which you usually already have:

    sudo aptitude install python-setuptools

You need MySQL-devel to compile, but its not called that, its called: libmysql++-dev on Ubuntu

    sudo apt-get install libmysql++-dev

download MySQLdb itself from:

    http://sourceforge.net/projects/mysql-python/

    # the version you download will be more recent

    tar xfz MySQL-python-1.2.3.tar.gz

    cd MySQL-python-1.2.3

    python setup.py build

    # the following might fail if it can't find mysql_config on your path

    sudo python setup.py install

    

if it did try locating the mysql_config that was installed with MySQL-devel

and editing site.cfg which is in the MySQL-python folder

uncomment and point to it here: 

    mysql_config = /usr/bin/mysql_config

  

and try to build again

if it worked then test:

open a python shell (also change directories out of the compile dir you were just in to avoid confusing yourself with the just compiled version sitting in your path)

    import MySQLdb


MySQLdb is the python support bindings for MySQL.  Not that the name would lead you to beleive that.


Its sourceforge page calls it http://sourceforge.net/projects/mysql-python/ which makes more sense.


you need setuptools, which you usually already have:


    sudo aptitude install python-setuptools


You need MySQL-devel to compile, but its not called that, its called: libmysql++-dev on Ubuntu


    sudo apt-get install libmysql++-dev


download MySQLdb itself from:


    http://sourceforge.net/projects/mysql-python/


    # the version you download will be more recent


    tar xfz MySQL-python-1.2.3.tar.gz


    cd MySQL-python-1.2.3


    python setup.py build


    # the following might fail if it can't find mysql_config on your path


    sudo python setup.py install


if it did try locating the mysql_config that was installed with MySQL-devel


and editing site.cfg which is in the MySQL-python folder


uncomment and point to it here: 


    mysql_config = /usr/bin/mysql_config


and try to build again


 

if it worked then test:


open a python shell (also change directories out of the compile dir you were just in to avoid confusing yourself with the just compiled version sitting in your path)


    import MySQLdb


 
 


  • more posts in tech notes
    • django has two classes called ValidationError

      There is one in django.core.exceptions and one in django.forms.util Using that space age IDE Eclipse I have to say I'm enjoying how much time I've saved just going shift-command-O to organize and resolve all of my imports.  But today I've just lost a few hours due to my ok-ing the wrong class. Quite mysterious it was, I raised a ValidationError (core exceptions one) in my form's clean() and watched as the try: except ValidationError: in django's full_clean() completely ignored my ...

    • GDAL fails to build: `.rodata' can not be used when making a shared object; recompile with -fPIC

        libtool: link: g++ -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.1/crtbeginS.o .libs/libgdal.la.lnkscript  -L/usr/local/lib /usr/local/lib/libgeos_c.so /usr/local/lib/libgeos.so /usr/local/lib/libexpat.so -L/usr/lib -lpq -lrt -ldl /usr/lib/libcurl.so -lssl -lcrypto -lz -L/usr/lib/gcc/x86_64-linux-gnu/4.4.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.4.1/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib/crtn.o         -Wl,-soname -Wl,libgdal.so.1 -o .libs/libgdal.so.1.13.2 /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libz.a: could not read symbols: Bad value collect2: ld returned 1 exit status make[1]: *** [libgdal.la] Error 1 make[1]: Leaving directory `/home/crucial/tmp/gdal-1.6.2' ...

    • postgres login as admin user postgres

      When installing postgres a user will be created named 'postgres' with a password of '!!' which means "cannot login".  But yet you need to login as that in order to run psql (the postgres db shell) to create other users and to create database templates. The solution is to first log yourself in as root (in your normal shell): su root (enter password...) then you will no longer be subject to password checks and you can login in as user ...

    • How to uninstall PyDev Extensions from Eclipse

      I'm enjoying Eclipse for Python Django development. The integrated lint check is great and has saved me much time already. Nearly automatic handling of imports is simply a life saver.  Imports are the most time consuming and frustrating aspect of python development and I always wished they would just resolve themselves. With Eclipse and PyDev they do ! I dream of one day getting the debugger and integrated unit tests to work properly.  It takes a while to get used ...

    • Full index for tech notes

Solar Life Raft Ingredients

Timeblind
Format: Digital
Release date: 4th January 2010
Available at
  • coltan and cassiterite Timeblind

The unmixed ingredients from Rupture and Shadetek’s Solar Life Raft. Including two tracks by me: Coltan and Cassiterite and Space Cadet (which came out on last year’s 12” on Version)

I’ve been waiting/yearning for Coltan and Cassiterite to come out for much of last year. I was about to release it myself just to relieve my own tension waiting for it. Anyway, its on a good home: The Agriculture and the reviews have been great so far.

The title refers to two of the minerals that are mined in the Democratic Republic of Congo and are components in portable electronics like cel phones. Its one of the unfortunate driving forces behind continuing warfare among the militias in the Rwanda/DRC border area.

Avail at boomkat: http://➯.ws/⚥ SLR in 320kMP3 and Flac

Downward Spiral (Timeblind Remix) Timeblind : Divided by Zero
Backwardation : Version 12"