找了一堆教程都沒搞定,順藤摸瓜得找,總算是總結(jié)出來了。
最有用的方案:
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
所以總結(jié)下來的步驟為:
# 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 (這個笑到我了,不過有時也會中招哈哈)