4

This is a bit of a complex problem, at least for me. Here it goes:

I'm working as a user on linux server and it's safe to assume that installing any package not already installed is simply impossible.

Also I need to set up working Python 2.5 (not installed) with working SQLite3 library (Sqlite in any form not installed).

What I can do is: 1. Compile Python 2.5 and make it work 2. Compile amalgamation of SQLite3

Anyway - Python 2.5 is supposed to have interaction with Sqlite3 built-in (pysqlite). It seems true enough, however importing sqlite3: import sqlite3 fails because - in the end - it is impossible to import _sqlite3

Some googling lead me to understand that while pysqlite may be built-in, the sqlite is not. Therefore I assumed that I need to built in locally sqlite and somehow make these two pieces of software interact.

Fair enough.

I'm able to - I hope so - compile amalgamation to shared object but it seems messy. Should I rename sqlite3.so to _sqlite3 and throw it somewhere? It seems fishy a bit, I tried it anyway and get an error: dynamic module does not define init function (init_sqlite3)

At this point I'm a bit stuck. I'm not too familiar with building/compiling stuff - I admit that sudo apt-get / sudo yum made me lazy but for some reason it is not an option at the moment.

Help appreciated!

4
  • did you do a "sudo apt-get install libsqlite3-dev" or install a similar package for your distribution before configuring Python? It should detect the optional dependencies automatically.
    – Niklas B.
    Dec 28, 2011 at 13:05
  • @Niklas, it seems he does not have sudo rights on this system. Dec 28, 2011 at 13:12
  • @Rob: Ah, I knew I was missing something..
    – Niklas B.
    Dec 28, 2011 at 13:27
  • Because I'm not an admin on the machine and I have to live with what I have :/
    – nimdil
    Dec 28, 2011 at 15:02

1 Answer 1

6

First download, build and install sqlite3 with a --prefix. Then build python with same prefix , it will find sqlite installation and will build _sqlite3 module.

$ mkdir -p ~/applications/src
$ cd ~/applications/src
$ wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
$ tar xvvf sqlite-autoconf-3070900.tar.gz
$ cd sqlite-autoconf-3070900
$ ./configure --prefix=~/applications
$ make
$ make install

$ cd ~/applications/src
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar xvvf Python-2.5.2.tgz
$ cd Python-2.5.2
$ ./configure --prefix=~/applications
$ make
$ make install

$ ~/applications/bin/python
>>> import sqlite3
>>> # no error!
2
  • 1
    Is there a way to replace just the _sqlite3 lib instead of having to rebuild an entire copy of python? I've got a case where I just want to "upgrade" my copy of sqlite a couple of revisions... Nov 9, 2012 at 22:24
  • I think we need to specify the path of sqlite header and library file for Python building although in some case the paths already existed in the default path config. stackoverflow.com/questions/26261080/…
    – http8086
    Sep 9, 2016 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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