【问题标题】:how to install psycopg2 on Mac (pg_config executable not found error)如何在 Mac 上安装 psycopg2(未找到 pg_config 可执行文件错误)
【发布时间】:2017-06-04 02:14:22
【问题描述】:

我正在学习如何将 Postgres 与 Python (sqlalchemy) 一起使用。我在安装psycopg2 时被卡住了。我有以下错误:

pg_config executable not found error

我知道这是一个非常常见的错误,并且已经有很多关于此的答案,但我找不到任何东西可以帮助我解决我的问题。

我特别不明白这个answers

通过附加 .profile 文件将 Postgres 的路径添加到 以下:

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

这是什么意思?我该怎么办?

我也尝试在终端中输入which -a pg_config,但没有任何反应。

非常感谢!

【问题讨论】:

  • 该解决方案有什么不清楚的地方?您需要更改环境变量PATH,以便可以找到pg_config
  • 我应该从我的终端执行此操作吗?我应该准确输入什么?
  • 您可以在终端中输入:PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"(如果这确实是找到pg_config 的路径),然后按回车键。然后构建psycopg2
  • 当我使用 mac 搜索栏搜索“pg_config”时,我什么也找不到。在我的终端中做which -a pg_config 什么都没发生。
  • 可能有一个 PostgreSQL 开发包你没有安装并且包含pg_config

标签: macos postgresql psycopg2


【解决方案1】:

问题已经解决了

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

在安装psycopg2之前进入终端窗口。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-20
    • 2018-03-24
    • 1970-01-01
    • 2013-12-08
    • 2021-02-14
    相关资源
    最近更新 更多