升级Linux上python3中使用的SQLite3版本吗?

升级Linux上python3中使用的SQLite3版本吗?

问题描述:

我需要升级我的python 3使用的sqlite3版本,但是似乎没有明确的答案,而且我不明白是什么决定了python使用的sqlite3版本.我正在安装python 3.6.4的情况下运行CentOS7.CentOS 安装了 3.7.17 版的 sqlite,我将其升级到 3.23.1,认为 python 也会使用这个从未使用过的 sqlite 版本.

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)

下面的代码仍然给我3.17.我已经用谷歌搜索了如何升级版本,但是大多数解决方案似乎是指pysqlite仅限于python 2.其他解决方案谈论复杂的编译过程,越过我的头.

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.

我不明白是什么决定了python使用的sqlite版本.它由python版本,操作系统安装的sqlite版本确定吗?我也在Windows PC上运行python 3.6.4,它说我正在运行3.14.2,因此sqlite版本似乎不依赖于python版本.

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.

什么决定了python使用的sqlite版本?有没有更直接的方法来升级python 3的sqlite版本?

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

sqlite3是一种外部库.所以,你需要设置外部库路径.

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

尝试下一个命令

printenv LD_LIBRARY_PATH

如果您以前从未设置过,结果将为空.

result will be empty, if you never set before.

next命令将使用为Python安装的sqlite3起作用

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)

,但是当您注销并再次登录时,此方法将被重置.因此,如果您希望每次登录时都注册该环境变量,则应编辑/etc/profile

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

并添加导出代码

export LD_LIBRARY_PATH="/usr/local/lib"

然后,如果您注销并再次登录,则可以看到LD_LIBRARY_PATH已注册.

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