Python:centos7.2中,python3安裝psycopg2

找了一堆教程都沒搞定,順藤摸瓜得找,總算是總結(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 (這個笑到我了,不過有時也會中招哈哈)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容