问题描述
我在 virtualenv 中安装 psycopg2 时遇到问题.
I had problems installing psycopg2 in a virtualenv.
我尝试了不同的解释:http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/
我尝试的最后一件事是...
我用 -p python2.5 --no-site-packages
创建了一个 virtualenv我安装了 libpq-dev:apt-get install libpq-dev
The last thing I tried is this...
I created a virtualenv with -p python2.5 --no-site-packages
I installed libpq-dev: apt-get install libpq-dev
在 virtualenv 中,我这样做了:easy_install -i http://downloads.egenix.com/python/index/ucs4/ egenix-mx-base
In the virtualenv, I did this: easy_install -i http://downloads.egenix.com/python/index/ucs4/ egenix-mx-base
然后当我尝试 pip install psycopg2==2.0.7
时,我得到这个错误:
Then when I tried pip install psycopg2==2.0.7
, I got this error:
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x080404 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/usr/include/python2.5 -I. -I/usr/include/postgresql -I/usr/include/postgresql/8.4/server -c psycopg/psycopgmodule.c -o build/temp.linux-i686-2.5/psycopg/psycopgmodule.o -Wdeclaration-after-statement
psycopg/psycopgmodule.c:27:20: error: Python.h: No such file or directory
In file included from psycopg/psycopgmodule.c:31:
./psycopg/python.h:31:26: error: structmember.h: No such file or directory
./psycopg/python.h:34:4: error: #error "psycopg requires Python >= 2.4"
In file included from psycopg/psycopgmodule.c:32:
有没有人知道如何解决这个问题?
谢谢.
Does anyone have any idea how to solve that?
Thanks.
推荐答案
来自 python-list:
From python-list:
迪兹:安装 python-dev-package.它包含 Python.h 文件,其中上面的错误信息很清楚说.通常,这是一个好主意搜索包描述丢失的 debian/ubuntu 软件包头文件以了解要安装的内容.
帕斯卡:它已经安装了;至少对于Python 2.6,也不确定它是否适合蟒蛇 2.5.python2.5-dev 不可用但是python-old-doctools 似乎取代了它.
迪兹:它是 100% 不 正确的蟒蛇2.5.如错误消息所示- 它不见了.如果某处不可用,您应该考虑构建python自己,如果你必须使用 2.5.
亚历克斯:Ubuntu 10.04 没有完整的Python 2.5 打包,证明缺少python2.5-dev.你需要使用 Python 2.6 或者如果你绝对必须使用 Python 2.5 从源,尝试 Debian 软件包或切换发行版.python-old-doctools 没有替换python-dev,看起来像准备保留一些乳胶工具工作.
Alex: Ubuntu 10.04 doesn't have a full Python 2.5 packaged, as evidenced by the lack of python2.5-dev. You need to use Python 2.6 or if you absolutely must use Python 2.5 build it from source, try a Debian package or switch distro. python-old-doctools does not replace python- dev, it looks like it was bodged to keep some latex tools working.
Pascal: 我终于创建了一个 virtualenv使用 Python 2.6 一切顺利(使用最新版本的 psycopg2).
这篇关于在 virtualenv 中安装 psycopg2(Ubuntu 10.04,Python 2.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!