Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've installed Python 2.6 from source on my Debian Lenny server, as Lenny does not have the python2.6 package. So, my Python 2.5 has MySQLdb installed and working just fine because I installed the python-mysqldb package.

I figured I could just install MySQLdb from source, but because I have the Lenny python-dev package, it builds against 2.5:

# python build
running build
running build_py
copying MySQLdb/ -> build/lib.linux-x86_64-2.5/MySQLdb
running build_ext
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/include/python2.5 -c _mysql.c -o build/temp.linux-x86_64-2.5/_mysql.o -DBIG_JOINS=1 -fPIC
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-2.5/_mysql.o -L/usr/lib/mysql -lmysqlclient_r -o build/lib.linux-x86_64-2.5/

I don't want to run python install, because I'm afraid it's going to screw up MySQLdb on 2.5 -- should I? I imagine it'd just overwrite 2.5 and do nothing to 2.6 -- maybe there's an argument I can use to install to 2.6? I imagine that I would need also to build against 2.6, so how do I do this?

share|improve this question

Turns out this is extremely easy! I realise now that it builds against whatever version of python you launch with - in my case I had python symlinked to python2.5

So, instead of running python, run python2.6:

# python2.6 build
running build
running build_py
creating build/lib.linux-x86_64-2.6
copying -> build/lib.linux-x86_64-2.6
creating build/lib.linux-x86_64-2.6/MySQLdb
-- snip --
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.