我试着安装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-command-line模式下输入
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“给出了”Python2.6.2“。提前感谢您的帮助。
发布于 2009-09-22 14:04:18
需要上一堂关于编译python扩展的课程,您使用的是哪个发行版?对于给定的宏定义,似乎缺少sqlite头文件。当python安装程序运行时,它将编译到sqlite本机二进制文件的绑定,并将一些.py文件复制到库中。_sqlite通常是一个.pyd文件(相当于一个dll),它调用了sqlite库,在您的例子中,这个库并没有被构建。
检查是否存在sqlite标头等。
发布于 2009-09-22 13:41:10
我忽略了最后一行,决定继续。
你不能忽略最后一行。它告诉你有一个错误,所以它不能编译。您运行的下一件事告诉您它无法安装,因为它无法编译。然后,您的python告诉您它无法运行代码,因为它没有安装。在继续安装之前,您需要使编译步骤正常工作。
发布于 2010-11-19 12:30:22
构建pysqlite的正确方法现在可以在网站上找到。
$ tar xvfz <version>.tar.gz
$ cd <version>
$ python setup.py build_static install build_static将下载最新的sqlite代码并对其进行静态编译。需要注意的是,我刚刚在1和1共享的主机上执行了此操作。
http://trac.edgewall.org/wiki/PySqlite#Buildingpysqlite
https://stackoverflow.com/questions/1460136
复制相似问题