报的错大致如下:

error: command 'gcc' failed with exit status

解决办法,安装postgres相关库:

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

最后,使用pip或者easy_install安装即可:

sudo pip install psycopg2