在Heroku上使用Python入门 - 找不到pg_config可执行文件

5 投票
1 回答
1675 浏览
提问于 2025-04-19 12:24

我一直在按照说明书操作,直到要安装requirements.txt文件的时候。每次尝试安装第6行“psycopg2==2.5.3”时都会失败。这里是错误信息 -

Downloading/unpacking psycopg2==2.5.3 (from -r requirements.txt (line 6))
Downloading psycopg2-2.5.3.tar.gz (690kB): 690kB downloaded
Running setup.py (path:/Users/pimpc/Sites/python/herokudemo/python-getting-started/venv/build/psycopg2/setup.py) egg_info for package 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'.
Complete output from command python setup.py egg_info:
running egg_info

creating pip-egg-info/psycopg2.egg-info

writing pip-egg-info/psycopg2.egg-info/PKG-INFO

writing top-level names to
pip-egg-info/psycopg2.egg-info/top_level.txt

writing dependency_links to
pip-egg-info/psycopg2.egg-info/dependency_links.txt

writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

warning: manifest_maker: standard file '-c' not found



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'.

当然,我在网上找到了很多相关的帖子。所以我开始检查各种情况。我认为Mac上的Postgres应用程序自带psycopg2。我已经把Postgres添加到了我的路径中,并在终端运行了“echo $PATH”来确认。我没有其他旧版本的冲突。而且Postgres的说明书上说我应该这样添加到我的路径中 -

export PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH:$PATH"

我已经重启了Postgres应用,停用了虚拟环境后又重新启动,但无论怎么做,错误依然存在。

我可能忽略了什么呢!我已经阅读了很多相关的帖子,甚至还有一些博客也讨论了这个问题。

1 个回答

2

我看到很多人都在遇到同样的错误,都是在用Postgres的Mac应用程序。于是我决定通过brew来安装Postgres,现在一切都运行得很好。

撰写回答