在 Debian 上升级 Python 的 sqlite3 [英] Upgrade Python's sqlite3 on Debian

查看:61
本文介绍了在 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.hsqlite3ext.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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆