Brian Peterson
Brian Peterson

Reputation: 2998

Missing sqlite3 after Python3 compile on Linux

My question is much like several others. Having manually compiled Python, sqlite3 is missing:

enter image description here

The main difference is that I'm using a Debian Linux system (unlike in this question: OS X 10.8.2 python 3 import sqlite error), and Python3 (unlike in this and a bunch of other questions: Cannot import SQLite with Python 2.6).

I was hoping for some guidance on which direction to troubleshoot in. According to some of the Linux-but-older-Python questions, an error like the one I'm getting could be caused by a missing resource during linking or something (_sqlite3.so). I have two such files on my system, both of them in older Python installations, ... but nothing related to Python3. Or is one of these good enough? Or they say to install the libsqlite3-dev package, then to re-compile Python. I did this, but I don't see how just having this package on my system will affect the compilation process. And indeed, it didn't. A second compile gave me a second Python without sqlite3.

I wish I could just do apt-get install python3, but Debian, in its stability, only has Python 3.2, where I need the latest version. Thoughts?

Upvotes: 27

Views: 34964

Answers (4)

Tom Orsi
Tom Orsi

Reputation: 51

I had this issue, the problem was that the shared object that implements pythons wrapper was missing from a point release of perl.

cp ~/.pyenv/versions/3.10.123.10.12/lib/python3.10/lib-dynload/_sqlite3.cpython-310-x86_64-linux-gnu.so ~/.pyenv/versions/3.10.12/3.10.13/lib/python3.10/lib-dynload/.

This was the copy I did to resolve the issue.

Upvotes: 0

wukong
wukong

Reputation: 2597

After apt-get install libsqlite3-dev

then

./configure --prefix=/opt/python3.7.4 --with-ssl --with-pydebug

make
make install

Note: You might need apt-get install libssl-dev aslo, openssl version must above 1.0.2 if you are compiling python3.7

For me, I'm using ubuntu 14.04 (trusty) I can't find a libssl-dev package to meet the requirement compiling python3.7 with ssl support. I modify my /etc/apt/sourcelist.d

deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted

after install a newer libssl-dev, then change it back to the original one

deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted

Upvotes: 26

QT-1
QT-1

Reputation: 996

If you only have limited user access (no root or sudo permission) you can install to a local, user accessible, environment like so:

tar -xvf sqlite-autoconf-3270200.tar.gz
cd sqlite-autoconf-3270200
./configure --prefix=$HOME/.local
make && make install

This will install on your ~/.local tree.

Add ~/.local/bin to your path if missing.

Upvotes: 3

Thomas Orozco
Thomas Orozco

Reputation: 55197

You need to install libsqlite3 (Debian based) or sqlite-devel (RedHat based) and the associated header files before compiling Python because Python needs to find them during the compile process.

Did you make sure to run:

  1. ./configure
  2. make
  3. make install

In this specific order? With no missing steps?

Upvotes: 27

Related Questions