python-can';t在centos 7上安装psycopg2

python-can';t在centos 7上安装psycopg2,python,django,postgresql,centos,Python,Django,Postgresql,Centos,我正在尝试在centos 7上配置Django 本文认为, 我安装了 sudo yum install python-pip python-devel postgresql-server postgresql-devel postgresql-contrib gcc nginx 在为Django设置PostgreSQL(如创建数据库)之后。。。 我尝试在virtualenv上安装psycopg2 pip install django gunicorn psycopg2 但是我犯了这个错误,

我正在尝试在centos 7上配置Django 本文认为,

我安装了

sudo yum install python-pip python-devel postgresql-server postgresql-devel postgresql-contrib gcc nginx 
在为Django设置PostgreSQL(如创建数据库)之后。。。 我尝试在virtualenv上安装psycopg2

pip install django gunicorn psycopg2
但是我犯了这个错误, 有人能帮我吗

Collecting psycopg2
  Using cached psycopg2-2.6.2.tar.gz
Installing collected packages: psycopg2
  Running setup.py install for psycopg2 ... error
    Complete output from command /usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-n0buiow5/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jk1w8dv1-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.4
    creating build/lib.linux-x86_64-3.4/psycopg2
    copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2
    copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2
    creating build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    running build_ext
    building 'psycopg2._psycopg' extension
    creating build/temp.linux-x86_64-3.4
    creating build/temp.linux-x86_64-3.4/psycopg
    gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090212 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
    In file included from psycopg/psycopgmodule.c:27:0:
    ./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-n0buiow5/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jk1w8dv1-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-n0buiow5/psycopg2/
收集psycopg2
使用缓存的psycopg2-2.6.2.tar.gz
安装收集的软件包:psycopg2
正在为psycopg2运行setup.py安装。。。错误
从命令/usr/bin/python3.4-u-c“import setuptools,tokenize;uuu file_uuu=”/tmp/pip-build-n0buiow5/psycopg2/setup.py';f=getattr(tokenize,'open',open)(uuu文件uuu);code=f.read()安装--record/tmp/pip-jk1w8dv1-record/install-record.txt--外部管理的单一版本--编译:
正在运行的安装
运行构建
运行build\u py
创建构建
创建build/lib.linux-x86_64-3.4
创建build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/tz.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/pool.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/extras.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/extensions.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/_range.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/uuu init_uuuu.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/psycopg1.py->build/lib.linux-x86_64-3.4/psycopg2
复制lib/_json.py->build/lib.linux-x86_64-3.4/psycopg2
正在复制lib/errorcodes.py->build/lib.linux-x86_64-3.4/psycopg2
创建build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test\u errcodes.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/dbapi20.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test\u bug\u gc.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test_async.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制tests/testconfig.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test_quote.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test_extras_dictcursor.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/测试类型\u basic.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test_transaction.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test\u cancel.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test_dates.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test_lobject.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/dbapi20_tpc.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test\u copy.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/测试类型\u extras.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test\u psycopg2\u dbapi20.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test_module.py->build/lib.linux-x86_64-3.4/psycopg2/tests
正在复制测试/_init__.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test_green.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制tests/testutils.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制tests/test_with.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test\u cursor.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test_connection.py->build/lib.linux-x86_64-3.4/psycopg2/tests
复制测试/test\u notify.py->build/lib.linux-x86\u 64-3.4/psycopg2/tests
复制测试/test_bugX000.py->build/lib.linux-x86_64-3.4/psycopg2/tests
跳过可选修复程序:缓冲区
跳过可选修复程序:习惯用法
跳过可选修复程序:set_literal
跳过可选修复程序:ws\u逗号
运行build_ext
构建“psycopg2.\u psycopg”扩展
创建build/temp.linux-x86_64-3.4
创建build/temp.linux-x86_64-3.4/psycopg
gcc-pthread-Wno unused result-DDYNAMIC\u ANNOTATIONS\u ENABLED=1-DNDEBUG-O2-g-pipe-Wall-Wp-D\u FORTIFY\u SOURCE=2-feexceptions-fstack protector-strong-param=ssp buffer size=4-grecord gcc switches-m64-mtune=generic-D\u GNU SOURCE-fPIC-fwrapv-fPIC-DPSYCOPG\u DEFAULT\u PYDATETIME=1-DPSYCOPG版本=“2.6.2(dt dec pq3 ext)”-DPG_VERSION_HEX=0x090212-I/usr/include/python3.4m-I-I/usr/include-I/usr/include/pgsql/server-c psycopg/psycopgmodule.c-o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o-Wdeclaration after语句
在psycopg/psycopgmodule.c中包含的文件中:27:0:
./psycopg/psycopg.h:30:20:致命错误:Python.h:没有这样的文件或目录
#包括
^
编译终止。
错误:命令“gcc”失败,退出状态为1
----------------------------------------
命令“/usr/bin/python3.4-u-c”导入setuptools,标记化__文件_uuu='/tmp/pip-build-n0buiow5/psycopg2/setup.py';f=getattr(标记化“打开”,打开)(_文件);code=f.read().replace('\r\n','\n');f、 close();exec(编译(代码,文件,exec'))“安装--record/tmp/pip-jk1w8dv1-record/install-record.txt--外部管理的单一版本--编译”失败,错误代码为/tmp/pip-build-n0buiow5/psycopg2中的1/

您似乎缺少一个

sudo-yum安装postgresql-libs

测试这个

yum安装python-psycopg2


安装
postgresql libs
没有帮助,它实际上需要一个有效的postgresql客户端。因此,安装适用于CentOS 7的devel软件包可以解决这个问题(如果这对您来说不算过分的话)

这是因为pip包停止附带postgresql客户端二进制文件,这很有意义,因为您可能希望在某些情况下使用不同的版本。

使用Python 3测试:

sudo yum groupinstall "Development Tools"
sudo yum install python3-devel
sudo yum install postgresql-libs
sudo yum install postgresql-devel
[sudo] pip install psycopg2
sudo yum groupinstall "Development Tools"
sudo yum install python3-devel
sudo yum install postgresql-libs
sudo yum install postgresql-devel
[sudo] pip install psycopg2