如何在 Mac 上安装 psycopg2(pg_config 可执行文件未找到错误)

how to install psycopg2 on Mac (pg_config executable not found error)

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

pg_config executable not found error

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

这个我特别不懂 answers :

add the path to Postgres to your .profile file by appending the following:

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

这是什么意思?我应该怎么做?

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

非常感谢!

问题已通过输入解决

PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
在安装 psycopg2.

之前

进入终端 window