gpt4 book ai didi

python - 在 virtualenv 中安装 psycopg2 (Ubuntu 10.04, Python 2.5)

转载 作者:太空宇宙 更新时间:2023-11-03 13:52:49 25 4
gpt4 key购买 nike

我在 virtualenv 中安装 psycopg2 时遇到问题。

我尝试了不同的解释: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

在 virtualenv 中,我这样做了:easy_install -i <a href="http://downloads.egenix.com/python/index/ucs4/" rel="noreferrer noopener nofollow">http://downloads.egenix.com/python/index/ucs4/</a> egenix-mx-base

然后当我尝试 pip install psycopg2==2.0.7 ,我得到了这个错误:

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:

有没有人知道如何解决这个问题?
谢谢。

最佳答案

来自 python 列表:

Diez: Install the python-dev-package. It contains the Python.h file, which the above error message pretty clearly says. Usually, it's a good idea to search package descriptions of debian/ubuntu packages for missing header files to know what to install.

Pascal: It's already installed; at least for Python 2.6, nor sure it's correct for Python 2.5. python2.5-dev is not available but python-old-doctools seems to replace it.

Diez: It is 100% not correct for python2.5. As the error message shows - it's missing. If it's not available somewhere, you should consider building python yourself, if you have to use 2.5.

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: I finally created a virtualenv with Python 2.6 and everything went fine (with the latest version of psycopg2).

关于python - 在 virtualenv 中安装 psycopg2 (Ubuntu 10.04, Python 2.5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3847536/

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