如何为 Python 2.4 构建 sqlite?
我想在Python和sdlite数据库之间使用pysqlite接口。我的计算机上已经安装了 Python 和 SQLite。但我在安装 pysqlite 时遇到了麻烦。在安装过程中我收到以下错误消息:
错误:命令“gcc”失败,退出状态为 1
据我所知,出现问题是因为我的Python版本是2.4.3,而SQLite从2.5开始就集成在Python中。然而,我还发现可以为 Python 2.4 构建 sqlite(可能使用一些技巧)。
有人知道如何为 Python 2.4 构建 sqlite 吗?
作为另一种选择,我可以尝试安装更高版本的 Python。但是我没有root权限。有谁知道解决问题的最简单方法是什么(从 Python 2.4 构建 SQLite,或安装更新版本的 Python)?我不得不提的是,我不想覆盖旧版本的Python。
先感谢您。
I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:
error: command 'gcc' failed with exit status 1
As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).
Does anybody know how to build sqlite for Python 2.4?
As another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以下载 Python 并将其安装到您的主目录。
然后,(如果您使用的是 bash)在 .bash_profile 中执行
然后,获取该文件以使其可用
,其中 python -V 将返回 python 版本。如果出现正确的版本,则使用 Python 的 setup.py util 运行的任何包(假设开发人员遵循正确的约定)都将安装在 ~/opt/lib/python2.x/site-packages 目录中。
You can download and install Python to your home directory.
Then, (if you are using bash) in your .bash_profile do
Then, source the file to make it available
where python -V will return the python version. If the correct version appears, any packages that you run with Python's setup.py util (assuming the developer followed the correct conventions) will install in ~/opt/lib/python2.x/site-packages directory.
此处下载 pysqlite, cd 进入您下载的目录,解压 tarball:
然后执行(如果您的权限设置正确;否则可能需要 sudo):
在丰富的输出中确实出现了一个错误:
因为很明显显示该文件仅用于 py 2.5 测试(2.4 中不存在
with
语句!-)。尽管如此,安装还是成功的:所有这些都是在 Mac OS X 10.5 上进行的,但使用的是与系统提供的 Python 2.5 分开安装的 python2.4。
您报告的错误并没有告诉我们太多信息——也许您缺少 sqlite 本身的标头或库?您能否向我们展示有关该单个错误消息的其他输出行...?
Download pysqlite here, cd into the directory you downloaded to, unpack the tarball:
then just do (if your permissions are set right for this; may need
sudo
otherwise):one error does appear in the copious output:
since as clearly shown that file is for py 2.5 tests only (
with
statement not present in 2.4!-). Nevertheless the install is successful:All this is on Mac OS X 10.5 but using python2.4 separately installed from the system-supplied Python 2.5.
The error you report doesn't tell us much -- maybe you're missing the headers or libraries for sqlite itself? Can you show us other output lines around that single error msg...?
如果您没有 root 权限,我建议您在主目录中安装更新版本的 Python,然后将本地版本添加到您的
PATH
中。沿着这个方向走似乎比尝试让 sqlite 与旧版本的 Python 一起工作更容易。使用最新版本的 Python 也会给你自己带来好处,因为你可以使用该语言的众多最新改进。
If you don't have root privileges, I would recommend installing a more recent version of Python in your home directory and then adding your local version to your
PATH
. It seems easier to go that direction than to try to make sqlite work with an old version of Python.You will also be doing yourself a favor by using a recent version of Python, because you'll have access to the numerous recent improvements in the language.
我也遇到了同样的问题,gcc 在 Ubuntu Karmic 上失败了。我通过安装 python-dev 包修复了这个问题。就我而言,我正在使用 python2.4,因此我安装了 python2.4-dev 包。 python-dev 包应该适用于 python2.6。
I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6.