python - 如何找到pg_config路径

标签 python django macos postgresql

这里完全是新手,正在尝试设置 Django 以与 PostgreSQL 一起使用。

我使用的是 mac osx 10.6.8。我还安装了 PostgreSQL 9.3

当我在终端中运行 pip install psycopg2 时,出现以下错误

Downloading/unpacking psycopg2
  Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
  Running setup.py (path:/private/var/folders/A9/A99cs6x0FNusPejCVkYNTE+++TI/-Tmp-/pip_build_bengorman/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'.

我看过很多关于此的帖子
how-to-install-psycopg2-with-pip-on-python
pg-config-executable-not-found

但我不知道如何找到包含 pg_config 的 bin 文件夹位置。关于找到这条路径有什么建议吗?

最佳答案

我建议您尝试使用Postgres.app。 (http://postgresapp.com) 这样您就可以轻松地在 Mac 上打开和关闭 Postgres。 完成后,通过附加以下内容将 Postgres 的路径添加到您的 .profile 文件中:

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

只有在将 Postgres 添加到路径后,您才能尝试在虚拟环境(使用 pip)或全局站点包中安装 psycopg2

关于python - 如何找到pg_config路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56080802/

相关文章:

python - 为什么/何时在 Python 中 `x==y` 调用 `y.__eq__(x)` ?

python - 使用 pydbus 库通过 session 总线发送信号

python - Django查询关系

python - 如何将不可编辑的字段添加到 Django 中的自定义管理表单

objective-c - WebView 中的后退/前进滑动手势

python - 在 HTTP 响应中返回图像

python - 如何按特定规则排序 django

xcode - 迪尔德 : lazy symbol binding failed: can't resolve symbol

macos - 获得不满意的权利

python - 如何索引张量并更改值