Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: command 'gcc' failed with exit status when installing psycopg2

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

This is my complete error with 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
like image 599
ws_123 Avatar asked Oct 16 '12 09:10

ws_123


3 Answers

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

like image 106
Jon Clements Avatar answered Nov 18 '22 03:11

Jon Clements


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

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
like image 32
Nicolás Ozimica Avatar answered Nov 18 '22 03:11

Nicolás Ozimica


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

sudo apt-get install python-dev

or

sudo apt-get install python3-dev
like image 14
Heroic Avatar answered Nov 18 '22 05:11

Heroic