https://packages.ubuntu.com/trusty/postgresql-server-dev-9.3
所以使用下面的命令即可安裝python-dev:
yum install python-devel
I just had to install this on my CentOS 6 server since psycopg2 required pg_config. Boo yah:
yum install postgresql-devel
Update
If you still encounter issues with pg_config, you may need to add it to your PATH, e.g.:
export PATH=$PATH:/usr/pgsql-x.x/bin
where x.x is your version, such as /usr/pgsql-9.2./bin.
You can install it from rpmforge or epel repo:
# yum install libpqxx-devel
I just run this command as a root from terminal and problem is solved,
sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
pip install psycopg2
or
sudo apt-get install libpq-dev python-dev
pip install psycopg2
================
sudo apt-get install postgresql
then fire:
sudo apt-get install python-psycopg2
and last:
sudo apt-get install libpq-dev
經過一番摸索,結合 psycopg2 的官方文檔,后來才發現需要把PostgreSQL的 libpq.so.5 跟系統的 libpq.so.5 進行替換,再重新安裝psycopg2,問題即可解決:
1、find what is the libpq dynamic library used at runtime(查找運行過程中所用的libpq動態庫):
$ ldd /path/to/packages/psycopg2/_psycopg.so | grep libpq
2、You can avoid the problem by using the same version of the pg_config at install time and the libpq at runtime(替換運行過程中的libpq動態庫):
root@localhost 17:26:46 /usr/local/download/psycopg2-2.6.1 => cd /usr/lib64 root@localhost 17:24:09 /usr/lib64 => rm libpq.so.5 root@localhost 17:24:09 /usr/lib64 => ln -s /usr/local/postgresql-9.4.0/lib/libpq.so.5 ./
3、重新安裝psycopg2,解決問題。
shenweiyan@localhost 20:24:34 /mydev/pyweb/download/psycopg2-2.5.4 => python Python 2.7.5 (default, Jan 13 2015, 13:32:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>>
-- 劉林強 136-1133-1997 liulinqiang@unipus.cn 北京外研在線教育科技有限公司 外語教學與研究出版社