views:

287

answers:

1

I want to install python to my local direcotory:

./configure --prefix=/home/alex/local-install && make && make install

When i import sqlite3 i get the following:

ImportError: No module named _sqlite3

the reason: there is no _sqlite3.so in /home/alex/local-install/lib/python2.6/lib-dynload.

How can i force python to build bindings for sqlite and other libraries (zlib for example)?

P.S. By the way: if i install sqlite3 to my local directory /home/alex/local-install before installing python - import sqlite3 works fine. That could be a solution: but in that case i have to install manually lots of libraries those i want to bind with python. Brrrrr :-[

+3  A: 

You need to install the development headers and libraries for sqlite somewhere where the Python build can find them. You didn't say what OS you have. On Linux you usually have to install additional -dev[el] packages to be able to build against a library.

Peter Eisentraut
Thanks a lot! I've installed sqlite3-dev and that solved the problem. Generally speaking, i want to compile python on my kubuntu machine and then move binaries to virtual shared hosting. Can mismatch of librariy versions couse problems?
alexdup
It depends on the project, but it's common for minor version changes to retain the ABI and major version number updates to require recompilation. If by ‘virtual shared hosting’ you mean a virtual root server where you can install dev packages yourself then I'd definitely recompile on that machine to avoid such problems.
bobince
@alexdup In general, you probably want to build binaries in a chroot or similar that matches the environment you deploy in. It's usually easy to set up and totally worth the avoided hassle.
Peter Eisentraut