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
相关产品推荐
相关产品推荐

