如何为 Python 2.4 构建 sqlite? [英] How to build sqlite for Python 2.4?

查看:34
本文介绍了如何为 Python 2.4 构建 sqlite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Python 和 sdlite 数据库之间使用 pysqlite 接口.我的电脑上已经有 Python 和 SQLite.但是我在安装 pysqlite 时遇到了麻烦.在安装过程中,我收到以下错误消息:

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:

错误:命令gcc"失败,退出状态为 1

error: command 'gcc' failed with exit status 1

据我所知,出现问题是因为我的 Python 版本是 2.4.3,而 SQLite 从 2.5 开始集成在 Python 中.但是,我也发现可以为 Python 2.4 构建 sqlite(可能使用一些技巧).

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).

有人知道如何为 Python 2.4 构建 sqlite 吗?

Does anybody know how to build sqlite for Python 2.4?

作为另一种选择,我可以尝试安装更高版本的 Python.但是我没有root权限.有谁知道解决问题的最简单方法是什么(从 Python 2.4 构建 SQLite,或安装更新版本的 Python)?我不得不提一下,我不想覆盖旧版本的 Python.

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.

提前致谢.

推荐答案

您可以下载 Python 并将其安装到您的主目录.

You can download and install Python to your home directory.

$ cd
$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz
$ tar xvzf Python-2.6.2.tgz
$ cd Python-2.6.2
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install

然后,(如果您使用 bash)在您的 .bash_profile 中做

Then, (if you are using bash) in your .bash_profile do

export PATH=$HOME/opt/bin/:$PATH
export PYTHONPATH=$HOME/opt/lib:$HOME/opt/lib/site-packages:$PYTHONPATH

然后,获取文件以使其可用

Then, source the file to make it available

$ cd
$ source .bash_profile
$ python -V

其中 python -V 将返回 python 版本.如果出现正确的版本,您使用 Python 的 setup.py util 运行的任何包(假设开发人员遵循正确的约定)将安装在 ~/opt/lib/python2.x/site-packages 目录中.

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.

这篇关于如何为 Python 2.4 构建 sqlite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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