gpt4 book ai didi

python - 为什么 pysqlite 不能正常工作?

转载 作者:太空宇宙 更新时间:2023-11-04 07:48:15 35 4
gpt4 key购买 nike

我尝试安装 pysqlite。安装过程中开始出现一些可疑的东西。为什么我输入:

python setup.py build

最后我得到了如下信息:

src/module.c:286: error: ‘SQLITE_PRAGMA’ undeclared here (not in a function)
src/module.c:287: error: ‘SQLITE_READ’ undeclared here (not in a function)
src/module.c:288: error: ‘SQLITE_SELECT’ undeclared here (not in a function)
src/module.c:289: error: ‘SQLITE_TRANSACTION’ undeclared here (not in a function)
src/module.c:290: error: ‘SQLITE_UPDATE’ undeclared here (not in a function)
src/module.c:291: error: ‘SQLITE_ATTACH’ undeclared here (not in a function)
src/module.c:292: error: ‘SQLITE_DETACH’ undeclared here (not in a function)
src/module.c: In function ‘init_sqlite’:
src/module.c:419: warning: implicit declaration of function ‘sqlite3_libversion’
src/module.c:419: warning: passing argument 1 of ‘PyString_FromString’ makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1

我只是忽略了最后一行并决定继续。所以,我输入:

python setup.py install

然后,我又收到了类似的错误消息:

src/module.c:288: error: ‘SQLITE_SELECT’ undeclared here (not in a function)
src/module.c:289: error: ‘SQLITE_TRANSACTION’ undeclared here (not in a function)
src/module.c:290: error: ‘SQLITE_UPDATE’ undeclared here (not in a function)
src/module.c:291: error: ‘SQLITE_ATTACH’ undeclared here (not in a function)
src/module.c:292: error: ‘SQLITE_DETACH’ undeclared here (not in a function)
src/module.c: In function ‘init_sqlite’:
src/module.c:419: warning: implicit declaration of function ‘sqlite3_libversion’
src/module.c:419: warning: passing argument 1 of ‘PyString_FromString’ makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1

之后我想试试 pysqlite 是否有效。如果在 python 命令行模式下我输入

from pysqlite2 import *

Python 不会提示。但是,如果我尝试遵循书中的示例:

from pysqlite2 import dbapi2 as sqlite

我收到一条错误消息:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pysqlite2/dbapi2.py", line 27, in <module>
from pysqlite2._sqlite import *
ImportError: No module named _sqlite

有没有人知道为什么会发生这种情况以及如何解决这个问题。顺便说一句,我已经安装了新版本的Python。 “python -V”给我“Python 2.6.2”。提前感谢您的帮助。

最佳答案

I just ignored the last line and decided to continue.

您不能只忽略最后一行。它告诉你有一个错误,所以它无法编译。您运行的下一件事告诉您它无法安装,因为它无法编译。然后,你的 python 告诉你它无法运行代码,因为它没有安装。在继续安装之前,您需要让编译步骤正常工作。

关于python - 为什么 pysqlite 不能正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1460136/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com