首页 > 解决方案 > “pip install psycopg2”在 Linux 上不起作用(找不到 pg_config 可执行文件)

问题描述

尝试使用以下命令在 Linux 上安装 psycopg2 软件包: pip install psycopg2

收到以下错误:

错误:找不到 pg_config 可执行文件。

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

运行“python setup.py build_ext --pg-config /path/to/pg_config build”后,

我收到以下错误:

“python:无法打开文件'setup.py':[Errno 2]没有这样的文件或目录”

有人可以解释我如何将包含 pg_config 的目录添加到 $PATH 吗?

另外,我在 virtualenv 中执行所有这些命令。

标签: pythonpathpippsycopg2pg-config

解决方案


推荐阅读