Python:centos7.2中,python3安装psycopg2

找了一堆教程都没搞定,顺藤摸瓜得找,总算是总结出来了。
最有用的方案:
https://stackoverflow.com/questions/11618898/pg-config-executable-not-found/12037133

# This is what worked for me on CentOS, first install:
sudo yum install postgresql postgresql-devel python-devel

# On Ubuntu just use the equivilent apt-get packages.
sudo apt-get install postgresql postgresql-dev python-dev

# And now include the path to your postgresql binary dir with you pip install, this should work for either Debain or RHEL based Linux:
sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2
# Make sure to include the correct path. Thats all :)

但是python3的话yum要安装的python-devel需要改为python3-devel
另外如果你不是root用户,最后一步建议为PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2 --user
所以总结下来的步骤为:

# for python3, centos
sudo yum install postgresql postgresql-devel python3-devel
PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2 --user

各位祝好!其他奇奇怪怪的报错放Link里

LINKS:
https://stackoverflow.com/questions/11618898/pg-config-executable-not-found/12037133
https://stackoverflow.com/questions/19843945/psycopg-python-h-no-such-file-or-directory
https://stackoverflow.com/questions/35104097/how-to-install-psycopg2-with-pg-config-error
https://serverfault.com/questions/316703/how-to-install-libpq-dev-on-centos-5-5 (一代版本一代名)
https://stackoverflow.com/questions/32576326/psycopg2-for-python3-on-centos-7 (这个笑到我了,不过有时也会中招哈哈)

你可能感兴趣的:(Python:centos7.2中,python3安装psycopg2)