Getting Around Linux: Compiling Python Extensions and Ubuntu’s Missing Packages

Last night I spent an awful lot of time trying to figure out how to compile an extension for Python. My struggles were quickly solved with the help of a charitable poster on Ubuntuforums.org. On default installations of Ubuntu 7.04 Fiesty, no development packages for the C compiler (aka gcc) and Python are included. In the end, the remedy was to install the C compiler and the Python development packages.

In order to accomplish this, type the following in the Bash prompt.

sudo apt-get install python-dev

This installs the Python development packages. You also need to type:

sudo apt-get install build-essential

This installs the C compiler.

After adding these magical packages, the extension I was trying to add compiled and was ‘successfully’ working. I put ‘successfully’ in quotes because I later found out that their were errors in the extension regarding a function call to localization, which was fixed about an hour later after some debugging.

Just in case you were wondering, the extension I was adding is called pgasync. It’s a asynchronous data adapter for PostgreSQL. If this works reliably, it may be able to scale better than using psycopg2, which is synchronous.

Leave a Reply