Missing sqlite3 after Python3 compile

跟風遠走 提交于 2019-12-02 05:17:19

问题


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

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?


回答1:


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?




回答2:


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



回答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.



来源:https://stackoverflow.com/questions/18750886/missing-sqlite3-after-python3-compile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!