You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7安装psycopg2-binary提示pg_config可执行文件找不到如何解决

CentOS 7环境安装psycopg2/psycopg2-binary报pg_config找不到问题解决方案

问题场景

在预装了PostgreSQL 12的CentOS 7系统的Django项目虚拟环境中,执行pip3 install psycopg2-binary安装依赖时出现如下报错:

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  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'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

已尝试的无效操作

  • 安装系统层面依赖包:python3-devel、postgresql-libs、postgresql-server、postgresql-devel、postgresql-contrib
  • 执行pip3 install psycopg2、pip install psycopg2命令安装
    以上操作完成后仍出现相同报错。

最终解决方案

升级pip版本即可解决,执行命令:

pip install --upgrade pip

内容的提问来源于stack exchange,提问作者thunderlion

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 04:30:04