Upgrading SQLite3 version used in python3 on linux?

浪尽此生 提交于 2020-12-25 04:29:38

问题


I need to upgrade the sqlite3 version that my python 3 uses but there seems to be no clear answers and I don't understand what determines the version of sqlite3 used by python. I am running CentOS7 with python 3.6.4 installed. CentOS had sqlite version 3.7.17 installed and I upgraded this to 3.23.1 thinking python would also use this never version of sqlite.

import sqlite3
print(sqlite3.sqlite_version)

The following code still gives me 3.17. I have googled how to upgrade the version but most solutions seem to refer to pysqlite which is python 2 only. Other solutions talk about complicated compiling processes that go way over my head.

I don't understand what determines the sqlite version that python uses. Is it determined by the python version, OS installed sqlite version? I am also running python 3.6.4 on my windows PC and it says I am running 3.14.2 so it seems that the sqlite version does not depend on the python version.

What determines the sqlite version python uses? Is there not a more straight forward way to upgrade the sqlite version for python 3?


回答1:


sqlite3 is kind of external library. so, you need to set external library path.

try next command

printenv LD_LIBRARY_PATH

result will be empty, if you never set before.

next command will work using installed sqlite3 for python

export LD_LIBRARY_PATH="/usr/local/lib"

then, you can execute and get correct version you installed

import sqlite3
print(sqlite3.sqlite_version)

but this method will be reset when you logout and login again. so, if you want to do regist that environment variable every time you login, you should edit /etc/profile

sudo vi /etc/profile

and add export code

export LD_LIBRARY_PATH="/usr/local/lib"

then, if you log-out and log-in again, you can see LD_LIBRARY_PATH is registered.




回答2:


In Ubuntu, you can add dqlite repository and update it using apt.

sudo add-apt-repository -y ppa:dqlite/stable
sudo apt update
sudo apt install sqlite3


来源:https://stackoverflow.com/questions/49920444/upgrading-sqlite3-version-used-in-python3-on-linux

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