找不到pg_config可执行文件

本文翻译自:pg_config executable not found

I am having trouble installing psycopg2. 我在安装psycopg2时遇到问题。 I get the following error when I try to pip install psycopg2 : 当我尝试pip install psycopg2时出现以下错误:

Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH

or specify the full executable path with the option:



    python setup.py build_ext --pg-config /path/to/pg_config build ...



or with the pg_config option in 'setup.cfg'.

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2

But the problem is pg_config is actually in my PATH ; 但是问题是pg_config实际上在我的PATH it runs without any problem: 它运行没有任何问题:

$ which pg_config
/usr/pgsql-9.1/bin/pg_config

I tried adding the pg_config path to the setup.cfg file and building it using the source files I downloaded from their website ( http://initd.org/psycopg/ ) and I get the following error message! 我尝试将pg_config路径添加到setup.cfg文件,并使用从其网站( http://initd.org/psycopg/ )下载的源文件进行构建,然后得到以下错误消息!

Error: Unable to find 'pg_config' file in '/usr/pgsql-9.1/bin/'

But it is actually THERE!!! 但是实际上是那里!!!

I am baffled by these errors. 这些错误使我感到困惑。 Can anyone help please? 有人可以帮忙吗?

By the way, I sudo all the commands. 顺便说一句,我sudo所有命令。 Also I am on RHEL 5.5. 我也在使用RHEL 5.5。


#1楼

参考:https://stackoom.com/question/mkba/找不到pg-config可执行文件


#2楼

pg_configpostgresql-devel (Debian / Ubuntu中的libpq-dev ,在Cygwin / Babun上的libpq-devel )。


#3楼

尝试将其添加到PATH:

PATH=$PATH:/usr/pgsql-9.1/bin/ ./pip install psycopg2

#4楼

Have you installed python-dev ? 您安装了python-dev吗? If you already have, try also installing libpq-dev 如果已经拥有,请尝试同时安装libpq-dev

sudo apt-get install libpq-dev python-dev

From the article: How to install psycopg2 under virtualenv 从文章: 如何在virtualenv下安装psycopg2


#5楼

apt-get build-dep python-psycopg2

#6楼

Just to sum up, I also faced exactly same problem. 综上所述,我也面临着完全相同的问题。 After reading a lot of stackoverflow posts and online blogs, the final solution which worked for me is this: 在阅读了很多stackoverflow帖子和在线博客之后,对我有用的最终解决方案是:

1) PostgreSQL(development or any stable version) should be installed before installing psycopg2. 1)在安装psycopg2之前,应先安装PostgreSQL(开发版或任何稳定版本)。

2) The pg_config file (this file normally resides in the bin folder of the PostgreSQL installation folder) PATH had to be explicitly setup before installing psycopg2. 2)在安装psycopg2之前,必须显式设置pg_config文件(该文件通常位于PostgreSQL安装文件夹的bin文件夹中)。 In my case, the installation PATH for PostgreSQL is: 就我而言,PostgreSQL的安装路径为:

/opt/local/lib/postgresql91/

so in order to explicitly set the PATH of pg_config file, I entered following command in my terminal: 因此,为了显式设置pg_config文件的PATH,我在终端中输入了以下命令:

PATH=$PATH:/opt/local/lib/postgresql91/bin/

This command ensures that when you try to pip install psycopg2, it would find the PATH to pg_config automatically this time. 此命令可确保当您尝试通过pip安装psycopg2时,它将自动找到pg_config的路径。

I have also posted a full error with trace and its solution on my blog which you may want to refer. 我还在我的博客上发布了有关跟踪及其解决方案的完整错误,您可能想参考一下。 Its for Mac OS X but the pg_config PATH problem is generic and applicable to Linux also. 它适用于Mac OS X,但是pg_config PATH问题是通用的,也适用于Linux。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当出现"pg_config executable not found"错误时,这意味着在安装psycopg2不到pg_config可执行文件pg_config是PostgreSQL的一个工具,用于提供有关PostgreSQL安装的信息。 解决此错误的方法之一是确保pg_config可执行文件位于系统的PATH环境变量中。您可以按照以下步骤操作: 1. pg_config可执行文件的路径。通常情况下,它位于PostgreSQL安装目录的bin文件夹中。 2. 将pg_config可执行文件的路径添加到系统的PATH环境变量中。具体步骤取决于您使用的操作系统。 - 在Windows上,您可以按照以下步骤操作: - 在开始菜单中搜索"环境变量"并打开"编辑系统环境变量"。 - 在系统属性对话框中,点击"环境变量"按钮。 - 在"系统变量"部分,到名为"Path"的变量,并点击"编辑"。 - 在编辑环境变量对话框中,点击"新建"并添加pg_config可执行文件的路径。 - 点击"确定"保存更改。 - 在Linux上,您可以编辑您的bash配置文件(例如~/.bashrc或/etc/profile)并将pg_config可执行文件的路径添加到PATH变量中。例如: ```shell export PATH=/path/to/pg_config:$PATH ``` 然后运行以下命令使更改生效: ```shell source ~/.bashrc ``` 3. 重新运行安装psycopg2的命令,应该不再出现"pg_config executable not found"错误。 请注意,如果您没有PostgreSQL安装或不需要使用psycopg2,您可以考虑使用其他适合您需求的库。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值