错误:安装psycopg2时命令'gcc'失败并退出状态

时间:2021-07-10 23:16:40

i need to install psycopg2 for openerp installation process, but i always found that error. i've already used pip and easy_install, my gcc is the latest version. Really need your help to solve my problem...

我需要为openerp安装过程安装psycopg2,但我总是发现错误。我已经使用了pip和easy_install,我的gcc是最新版本。真的需要你的帮助来解决我的问题......

this is my complete error with easy_install..

这是我使用easy_install的完整错误..

[root@server01 ~]# easy_install psycopg2    
Searching for psycopg2    
Reading http://pypi.python.org/simple/psycopg2/    
Reading http://initd.org/psycopg/    
Reading http://initd.org/projects/psycopg2    
Best match: psycopg2 2.4.5    
Downloading http://initd.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.5.tar.gz    
Processing psycopg2-2.4.5.tar.gz    
Running psycopg2-2.4.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-anWVvJ/psycopg2-2.4.5/egg-dist-tmp-cZbdtn

no previously-included directories found matching 'doc/src/_build' In file included from psycopg/psycopgmodule.c:27:
./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory In file included from psycopg/psycopgmodule.c:29:

...

error: Setup script exited with error: command 'gcc' failed with exit status 1

10 个解决方案

#1


31  

You'll need to install the development package for PostgreSQL, which for instance under Ubuntu is a sudo apt-get install libpq-dev... and for CentOS it's yum install postgresql-devel

你需要安装PostgreSQL的开发包,例如在Ubuntu下面是一个sudo apt-get install libpq-dev ...而对于CentOS来说它是yum install postgresql-devel

#2


27  

For the case of CentOS, I had this very same problem, that I solved installing these packages:

对于CentOS的情况,我遇到了同样的问题,我解决了安装这些软件包的问题:

sudo yum install postgresql-libs
sudo yum install postgresql-devel
sudo yum install python-devel

only then, I was able to perform successfully:

只有这样,我才能成功地执行:

sudo easy_install psycopg2

#3


14  

May Your system is missing the Python headers. To fix this, run:

可能您的系统缺少Python标头。要解决此问题,请运行:

sudo apt-get install python-dev

or

要么

sudo apt-get install python3-dev

#4


7  

On a fresh ubuntu 14.04.2 LTS on an EC2 instance, I was able to install psycopg2 after instaling the following packages:

在EC2实例上的新的ubuntu 14.04.2 LTS上,我能够在安装以下软件包后安装psycopg2:

sudo apt-get install gcc
sudo apt-get install postgres-xc-server-dev
sudo apt-get install libpq-dev
sudo apt-get install postgresql-client-common
sudo apt-get install postgresql-common

And on a fresh AMI linux (CentOS) instance:

在一个新的AMI linux(CentOS)实例上:

sudo yum install postgresql-devel
sudo yum install gcc*

Hope it helps,

希望能帮助到你,

Erez

埃雷兹

#5


5  

I've been trying to install pgsql on a plain Amazon Linux EC2 instance, and have been getting this error. Per Nicolás answer, I installed his suggested list of packages, but I continued to get the error. Looking more closely at the error, I noticed that the gcc command was including pgsql93 files:

我一直在尝试在普通的Amazon Linux EC2实例上安装pgsql,并且一直在收到此错误。 PerNicolás回答,我安装了他建议的包列表,但我继续得到错误。仔细查看错误,我注意到gcc命令包含pgsql93文件:

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.1 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x09030A -DHAVE_LO64=1 -I/usr/include/python2.7 -I. -I/usr/include/pgsql93 -I/usr/include/pgsql93/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE = 2 -fexceptions -fstack-protector -param = ssp-buffer-size = 4 -m64 -mtune = generic -D_GNU_SOURCE - fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE = 2 -fexceptions -fstack-protector -param = ssp-buffer-size = 4 -m64 -mtune = generic -D_GNU_SOURCE -fPIC -fwrapv - fPIC -DPSYCOPG_DEFAULT_PYDATETIME = 1 -DPSYCOPG_VERSION =“2.6.1(dt dec pq3 ext lo64)” - DPG_VERSION_HEX = 0x09030A -DHAVE_LO64 = 1 -I / usr / include / python2.7 -I。 -I / usr / include / pgsql93 -I / usr / include / pgsql93 / server -c psycopg / psycopgmodule.c -o build / temp.linux-x86_64-2.7 / psycopg / psycopgmodule.o -Wdeclaration-after-statement

Looking in /usr/include/ I see pgsql92/ but not pgsql93/. So I took a look at what pgsql-related yum packages were installed and I noticed these:

查看/ usr / include /我看到pgsql92 /但不是pgsql93 /。所以我看看安装了什么与pgsql相关的yum软件包,我注意到了这些:

postgresql92.x86_64 postgresql92-devel.x86_64 postgresql92-libs.x86_64 postgresql93.x86_64 postgresql93-libs.x86_64

postgresql92.x86_64 postgresql92-devel.x86_64 postgresql92-libs.x86_64 postgresql93.x86_64 postgresql93-libs.x86_64

Seemed to me like there ought to be a postgresql93-devel, so I tried:

对我来说就像应该有一个postgresql93-devel,所以我试过:

sudo yum install postgresql93-devel

sudo yum install postgresql93-devel

And that fixed the problem for me! So I guess the theme is: Look at the gcc call, and see what dir it's pulling in. Follow the crumbs from there.

这解决了我的问题!所以我猜主题是:看看gcc的调用,看看它是什么导入的。跟随那里的面包屑。

#6


3  

In centos 7. i'd use sudo yum install postgresql96-devel.x86_64 to solved my problem.

在centos 7.我使用sudo yum install postgresql96-devel.x86_64来解决我的问题。

#7


2  

The invocation of gcc failed, gcc couldn't compile the source. Probably the cause is

gcc的调用失败了,gcc无法编译源代码。原因可能是

./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory In file included from psycopg/psycopgmodule.c:29:

that the header libpq-fe.h is nowhere in the search path if you have it at all.

如果您拥有它,那么头文件libpq-fe.h在搜索路径中是无处可去的。

#8


2  

For Ubuntu 14.04, from Docker image python:3.4.3-slim this combination worked for me:

对于Ubuntu 14.04,来自Docker image python:3.4.3-slim这个组合对我有用:

sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y python3.4-dev
sudo apt-get install -y libpq-dev

pip3 install psycopg2

Note build-essential package. It was crucial in my case.

注意build-essential包。这对我来说至关重要。

#9


1  

For me, the missing package was

对我来说,丢失的包裹是

libpqxx-devel.x86_64

#10


1  

This worked for me on Ubuntu Server 14.10 64-bit:

这在Ubuntu Server 14.10 64位上对我有用:

sudo apt-get install libpqxx-dev

#1


31  

You'll need to install the development package for PostgreSQL, which for instance under Ubuntu is a sudo apt-get install libpq-dev... and for CentOS it's yum install postgresql-devel

你需要安装PostgreSQL的开发包,例如在Ubuntu下面是一个sudo apt-get install libpq-dev ...而对于CentOS来说它是yum install postgresql-devel

#2


27  

For the case of CentOS, I had this very same problem, that I solved installing these packages:

对于CentOS的情况,我遇到了同样的问题,我解决了安装这些软件包的问题:

sudo yum install postgresql-libs
sudo yum install postgresql-devel
sudo yum install python-devel

only then, I was able to perform successfully:

只有这样,我才能成功地执行:

sudo easy_install psycopg2

#3


14  

May Your system is missing the Python headers. To fix this, run:

可能您的系统缺少Python标头。要解决此问题,请运行:

sudo apt-get install python-dev

or

要么

sudo apt-get install python3-dev

#4


7  

On a fresh ubuntu 14.04.2 LTS on an EC2 instance, I was able to install psycopg2 after instaling the following packages:

在EC2实例上的新的ubuntu 14.04.2 LTS上,我能够在安装以下软件包后安装psycopg2:

sudo apt-get install gcc
sudo apt-get install postgres-xc-server-dev
sudo apt-get install libpq-dev
sudo apt-get install postgresql-client-common
sudo apt-get install postgresql-common

And on a fresh AMI linux (CentOS) instance:

在一个新的AMI linux(CentOS)实例上:

sudo yum install postgresql-devel
sudo yum install gcc*

Hope it helps,

希望能帮助到你,

Erez

埃雷兹

#5


5  

I've been trying to install pgsql on a plain Amazon Linux EC2 instance, and have been getting this error. Per Nicolás answer, I installed his suggested list of packages, but I continued to get the error. Looking more closely at the error, I noticed that the gcc command was including pgsql93 files:

我一直在尝试在普通的Amazon Linux EC2实例上安装pgsql,并且一直在收到此错误。 PerNicolás回答,我安装了他建议的包列表,但我继续得到错误。仔细查看错误,我注意到gcc命令包含pgsql93文件:

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.1 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x09030A -DHAVE_LO64=1 -I/usr/include/python2.7 -I. -I/usr/include/pgsql93 -I/usr/include/pgsql93/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE = 2 -fexceptions -fstack-protector -param = ssp-buffer-size = 4 -m64 -mtune = generic -D_GNU_SOURCE - fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE = 2 -fexceptions -fstack-protector -param = ssp-buffer-size = 4 -m64 -mtune = generic -D_GNU_SOURCE -fPIC -fwrapv - fPIC -DPSYCOPG_DEFAULT_PYDATETIME = 1 -DPSYCOPG_VERSION =“2.6.1(dt dec pq3 ext lo64)” - DPG_VERSION_HEX = 0x09030A -DHAVE_LO64 = 1 -I / usr / include / python2.7 -I。 -I / usr / include / pgsql93 -I / usr / include / pgsql93 / server -c psycopg / psycopgmodule.c -o build / temp.linux-x86_64-2.7 / psycopg / psycopgmodule.o -Wdeclaration-after-statement

Looking in /usr/include/ I see pgsql92/ but not pgsql93/. So I took a look at what pgsql-related yum packages were installed and I noticed these:

查看/ usr / include /我看到pgsql92 /但不是pgsql93 /。所以我看看安装了什么与pgsql相关的yum软件包,我注意到了这些:

postgresql92.x86_64 postgresql92-devel.x86_64 postgresql92-libs.x86_64 postgresql93.x86_64 postgresql93-libs.x86_64

postgresql92.x86_64 postgresql92-devel.x86_64 postgresql92-libs.x86_64 postgresql93.x86_64 postgresql93-libs.x86_64

Seemed to me like there ought to be a postgresql93-devel, so I tried:

对我来说就像应该有一个postgresql93-devel,所以我试过:

sudo yum install postgresql93-devel

sudo yum install postgresql93-devel

And that fixed the problem for me! So I guess the theme is: Look at the gcc call, and see what dir it's pulling in. Follow the crumbs from there.

这解决了我的问题!所以我猜主题是:看看gcc的调用,看看它是什么导入的。跟随那里的面包屑。

#6


3  

In centos 7. i'd use sudo yum install postgresql96-devel.x86_64 to solved my problem.

在centos 7.我使用sudo yum install postgresql96-devel.x86_64来解决我的问题。

#7


2  

The invocation of gcc failed, gcc couldn't compile the source. Probably the cause is

gcc的调用失败了,gcc无法编译源代码。原因可能是

./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory In file included from psycopg/psycopgmodule.c:29:

that the header libpq-fe.h is nowhere in the search path if you have it at all.

如果您拥有它,那么头文件libpq-fe.h在搜索路径中是无处可去的。

#8


2  

For Ubuntu 14.04, from Docker image python:3.4.3-slim this combination worked for me:

对于Ubuntu 14.04,来自Docker image python:3.4.3-slim这个组合对我有用:

sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y python3.4-dev
sudo apt-get install -y libpq-dev

pip3 install psycopg2

Note build-essential package. It was crucial in my case.

注意build-essential包。这对我来说至关重要。

#9


1  

For me, the missing package was

对我来说,丢失的包裹是

libpqxx-devel.x86_64

#10


1  

This worked for me on Ubuntu Server 14.10 64-bit:

这在Ubuntu Server 14.10 64位上对我有用:

sudo apt-get install libpqxx-dev