27

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?

4 Answers 4

27

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?

Sign up to request clarification or add additional context in comments.

8 Comments

How do I make Python find them during the compile process? I mentioned that I had tried installing that exact package.
@Bepetersn I was updating the answer, can you check you did follow those three steps? If it still doesn't work, can you show any warnings that show up during the compile process?
@Bepetersn the key step here is ./configure. You should check its output for sqlite3.
When I complied python 2.7 by hand on RHEL6, the compiler would crash while trying to build the sqlite3 module due to a 64-bit error and a typedef. (Not sure where I found that link) Try compiling python again, and look very closely at the output and see why (I think) the sqlite module is crashing during compilation.
@Bepetersn For future reference, configure is the step that searches for available libraries. Header files (those contained in the -dev package) are files that tell the compiler how to build against the sqlite binaries that are on your system.
|
26

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

1 Comment

1. --with-ssl seems not required now 2. libffi-dev is aslo required, otherwise there will be an error "No module named '_ctypes' when using Value from module multiprocessing" when make install
3

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.

Comments

0

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.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.