Upgrade Python#39;s sqlite3 on Debian(在 Debian 上升级 Python 的 sqlite3)
问题描述
我在我的 Debian 上的 linux2 上使用 Python 2.7.6(默认,2014 年 3 月 22 日,22:59:56)[GCC 4.8.2],我通常使用模块 sqlite3 没有任何问题.
I'm using Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 on my Debian, and I'm usually using module sqlite3 without any problem.
我 编译了一个 Sqlite 扩展 spellfix,加载时出现此错误:
I compiled a Sqlite extension spellfix, I get this error when loading it:
sqlite3.OperationalError: ./spellfix.so: undefined symbol: sqlite3_malloc64
sqlite3.OperationalError: ./spellfix.so: undefined symbol: sqlite3_malloc64
我认为可能是因为 sqlite3 模块太旧:
I think it might be because the sqlite3 module is too old:
import sqlite3
print sqlite3.version # 2.6.0
print sqlite3.sqlite_version # 3.8.2
(在 sqlite3.sqlite_version 为 3.8.7.x 的另一台机器上,扩展加载正常).
(On another machine where sqlite3.sqlite_version is 3.8.7.x the extension loads fine).
我试过了:
pip install --upgrade pysqlite
但还是一样:sqlite3.sqlite_version 保持 3.8.2.
but it's still the same: sqlite3.sqlite_version stays 3.8.2.
如何升级 Python sqlite3 模块(标准库内置)?
推荐答案
您认为是 sqlite3 的版本导致了问题.sqlite_malloc64 是在 release 3.8.7 中引入的.
You are right in thinking that the version of sqlite3 causes the problem. sqlite_malloc64 was introduced with release 3.8.7.
我建议不要尝试升级 Python sqlite3 模块(这可能会破坏您的 Python 安装),而是建议编译 3.8 版中包含的 spellfix.c 版本.2.
Instead of trying to upgrade the Python sqlite3 module which may end up breaking your Python installation, I would suggest compiling the version of spellfix.c included with version 3.8.2.
你可以在这里找到源代码:https://www.sqlite.org/src/tarball/27392118/SQLite-27392118.tar.gz
You can find the source here: https://www.sqlite.org/src/tarball/27392118/SQLite-27392118.tar.gz
从那里你可以建立合并:
From there you can build the amalgamation with:
sh configure
make sqlite3.c
您将在 tsrc 文件夹中拥有 sqlite3.h 和 sqlite3ext.h.然后编译 spellfix.c 扩展:
You will have sqlite3.h and sqlite3ext.h in the tsrc folder. Then compile the spellfix.c extension with:
gcc -g -fPIC -shared spellfix.c -I ../../tsrc -o spellfix.dll
你应该得到一个兼容的 spellfix.dll 与你的 sqlite3 版本一起运行.
And you should get a compatible spellfix.dll that runs with your version of sqlite3.
这篇关于在 Debian 上升级 Python 的 sqlite3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Debian 上升级 Python 的 sqlite3
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
