尝试安装psycopg2模块时在CentOS上缺少libpq头文件

问题描述:

我一直在搜索网络几小时,结束几天,我无法在我的Linux机器上安装psycopg2库(CentOS - 2.6.32-431.3.1。 el6.x86_64 GNU/Linux)。尝试安装psycopg2模块时在CentOS上缺少libpq头文件

我知道,问题是,我很想念libpq的头文件,因为我试图PIP安装psycopg2后收到此消息:libpq-fe.h: No such file or directory

http://initd.org/psycopg/docs/install.html#install-from-source

几乎所有我发现文章指出我用apt-get在CentOS上,但apt-get不是CentOS 6.3上的标准工具,所以我一直尝试yum install

但是,每次我尝试使用sudo yum install下载某些软件包时都不可用。例如:

yum install postgresql-devel Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile drivesrvr | 2.2 kB 00:00 No package postgresql-devel available. Error: Nothing to do

我试过这样的:

  1. 百胜安装PostgreSQL服务器
  2. 百胜安装python-devel的
  3. 服务的PostgreSQL initdb的
  4. 服务的PostgreSQL启动
  5. yum install python-psycopg2

任何想法?没有libpq头文件,我无法安装我的Python程序所必需的psycopg2模块。这是为Python 2.7.12。和PostgreSQL 9.3.13。

我在亚马逊的Fedora 2016.09上有这个问题。我可以通过yum安装postgresql-devel,但这并没有办法;该版本似乎已过时。

我解决它使用:

sudo yum install /usr/include/libpq-fe.h 

这将安装PostgreSQL的-devel的一个更新版本,它允许psycopg2正确编译通过PIP安装时。