Cannot Import SQLite with Python 2.6 in Ubuntu Natty
Posted by sky | Tags: Linux, Python, Ubuntu, installation
I am compiling Python 2.6 on Ubuntu Natty. All the sqlite3 development headers and libraries are already installed.
$ make
.. .. ..
Failed to find the necessary bits to build these modules:
_bsddb _sqlite3 bsddb185
dbm gdbm sunaudiodev
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module'
s name.
Failed to build these modules:
crypt nis
After some checking, it turns out that the libsqlite3.so file is not in the /usr/lib dir, instead it is found in the /usr/lib/i386-linux-gnu dir. According to Barry Warsaw (The impact of multiarch on upstream Python), the .so files are moved to arch-specific directories, e.g. libsqlite3 to /usr/lib/x86_64-linux-gnu. Ubuntu's Python packages broke because Python's build process does not look in the arch directories when it tries to figure out which extension modules it can build. There is a Python issue: Building Python on multiarch Debian and Ubuntu.
The easy solution is to create some symlinks in the /usr/lib dir:
$ cd /usr/lib
$ sudo ln -s i386-linux-gnu/libsqlite3.so.0.8.6 libsqlite3.so
$ sudo ln -s i386-linux-gnu/libz.so libz.so
$ sudo ln -s i386-linux-gnu/libcrypt.so libcrypt.so
$ sudo ln -s i386-linux-gnu/libnsl.so libnsl.so
After that, make will be able to compile those modules.
$ make
.. .. ..
Failed to find the necessary bits to build these modules:
_bsddb bsddb185 dbm
gdbm sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module'
s name.
$ sudo make install
Previous Post
Next Post