我已经在CentOS7.4框上安装了Python3.6,并且需要更新版本的SQLite (我正在使用一些新特性)。它附带的SQLite版本非常旧: 3.7.17。
这是怎么做的?在Windows上,用您想要的sqlite.dll目录替换Python目录中的文件很简单,但是我没有发现如何在Linux上这样做。
我可以看到之前有人问过这个问题,但没有回答-- https://stackoverflow.com/questions/39064472/how-to-update-sqlite3-in-centos-6-6 --这是我搜索的唯一页面;其他大多数结果都是Python2/pysqlite,但对我没有帮助。
那么,如何更新SQLite在CentOS框中使用的版本呢?
发布于 2018-03-28 14:49:28
您需要找到一个带有更新版本的RPM,或者需要下载操作系统的预编译二进制文件(https://www.sqlite.org/download.html),或者下载源代码/编译/安装软件。
通常建议使用RPM,以便更好地管理软件(用于安装、升级等)。不过,如果您找不到将工作的RPM,可以尝试安装预编译版本或编译软件并安装。这通常是在Linux系统上完成的,以获得运行特定软件所需的最新或特定版本的软件。
编译SQLite之后,您应该能够指向python的库,一种快速的方法是将LD_LIBRARY_PATH设置为从SQLite编译中获得的lib目录的输出:
Libraries have been installed in: /usr/local/sqlite-3.22.0/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the '-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the 'LD_RUN_PATH' environment variable during linking - use the '-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to '/etc/ld.so.conf'
如果在设置库之前运行python,您将看到旧版本:
python3.6 -c "import sqlite3; print(sqlite3.sqlite_version)"
3.7.17
新版本:
export LD_LIBRARY_PATH=/usr/local/sqlite-3.22.0/lib
python3.6 -c "import sqlite3; print(sqlite3.sqlite_version)"
3.22.0
根据您的环境,您可能需要在代码中或在代码运行之前设置这一点,这取决于您如何管理不同版本的库。尽管编译的输出可以给您一些关于这方面的想法。
https://unix.stackexchange.com/questions/434100
复制相似问题