Python 2.5, Sqlite, and the obvious

by Jeremy Jones

I wanted to get a Django site working under Python 2.5 the other day using Sqlite. I downloaded the source for Python 2.5 (even though 2.5 is in the Ubuntu repository), compiled, downloaded the Django 0.95 release, installed it, and tried to create a new blank database. Error. Here is the exact traceback:

Traceback (most recent call last):
File "", line 2, in
from import execute_manager
ImportError: No module named

After digging for a few minutes, I realized that I didn't have the Sqlite header files on my system when I compiled Python. I added the libsqlite-dev package on my laptop (which is running Ubuntu), did the make && make install dance, and tried it again. No error.

Had I taken the time to read all 1291 lines of the README in the Python 2.5 release, I would have read this around line 760:

Building the sqlite3 module

To build the sqlite3 module, you'll need the sqlite3 or libsqlite3
packages installed, including the header files. Many modern operating
systems distribute the headers in a separate package to the library -
often it will be the same name as the main package, but with a -dev or
-devel suffix.

The version of pysqlite2 that's including in Python needs sqlite3 3.0.8
or later. attempts to check that it can find a correct version.

Now all is well with the world.


2006-11-16 07:52:37
Why should we care for the fact that you had problems that could have been avoided if you had read the README file ? Why do you think the file is called README and not DISREGARDME ?
Jeremy Jones
2006-11-16 08:19:30

Thanks for the comment. I posted because I thought (and still think) that readers may find it useful if they install/compile Python 2.5 and Sqlite isn't "just working" as it's a new feature. If they have, say, the libsqlite package installed, they may be curious why sqlite isn't working. And if they have a 1200+ line README file, it may be quicker to hit Google than Vim. Or maybe the average user may hit Google and not even think about looking at the README. Actually, I didn't read the README until after I had fixed the problem to confirm that they had, in fact, mentioned what needed to be done in order to get Sqlite working. Anyway, thanks for the comments.

Noah Gift
2006-12-22 08:35:57
Thanks for the posting Jeremy. I actually do enjoy honest and real life examples like the one you posted. Sometimes if your in the thick of things and you really need to get something running you don't have time to read 1,500 lines of documentation several times per day, and you wing it by hoping you can fix any problems with intuition and luck. Keep up the good work and real life example postings. I find them refreshing as many people don't have the guts to be honest when posting technical articles.

In fact, I am especially glad you posted this example as I am about to compile python 2.5 and do some django development work on my python 2.4.3 ubuntu box.

Jeremy Jones
2006-12-27 04:47:48
Thanks for the kind words, Noah. I feel like a blog is a good place to be transparent. That includes sometimes blogging stupid mistakes and hopefully prevent others folks from falling into the same trap. Hope all is well with your Django and Python 2.5. I haven't hit any problems yet, save the non-problem mentioned above.
2007-05-30 11:32:05
What's make && make install dance, and exactly what steps did you take to solve your problem?
Jeremy M. Jones
2007-05-30 11:59:56

The "make && make install" dance was just compiling from source on Linux. I had to install the headers for the sqlite library so Python would compile against it. Installing the headers first then compiling Python from source fixed my problem.

Andrew Pennebaker
2008-08-09 17:40:16
Oh, believe me I have problems today (that's two years later!) setting up Django and SQLite. I'm a Ruby on Rails fan, though I was using Python before that. One day I decided to see how Django compared, but after the pain of seeing manual installs of Django, Python-SQLite, and Python-MySQL fail, I don't have time to waste. I really wish Guido would champion a package system like RubyGems, so I wouldn't have to putt around with manual builds that freaking fail.