Python 为我的Mac安装psycopg2时出错

Python 为我的Mac安装psycopg2时出错,python,Python,我正试图在虚拟环境中的mac上安装psycopg2软件包,以便使用Heroku部署我的项目。我得到这个错误:找不到pg_config可执行文件。我已经尝试过pip安装psycog2二进制文件,但当我去安装django heroku时,仍然会出现相同的错误。您知道如何修复此问题以安装psycopg2软件包吗 pg_config is required to build psycopg2 from source. Please add the directory containing pg_con

我正试图在虚拟环境中的mac上安装psycopg2软件包,以便使用Heroku部署我的项目。我得到这个错误:找不到pg_config可执行文件。我已经尝试过pip安装psycog2二进制文件,但当我去安装django heroku时,仍然会出现相同的错误。您知道如何修复此问题以安装psycopg2软件包吗

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

or with the pg_config option in 'setup.cfg'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).

----------------------------------------
从源代码构建psycopg2需要pg_配置。请添加目录 将pg_config包含到$PATH,或使用 选项: python setup.py build_ext--pg config/path/to/pg_config build。。。 或者使用'setup.cfg'中的pg_config选项。 如果您希望避免从源代码构建psycopg2,请安装PyPI 改为“psycopg2二进制”包。 有关更多信息,请查看“doc/src/install.rst”文件(另请访问 ). ---------------------------------------- “请安装PyPI‘psycopg2二进制文件’”

您可以通过运行以下命令来完成此操作

pip install psycopg2-binary

当您执行pip安装psycopg2 binary时,它会说些什么?这是否回答了您的问题?值得注意的是,当您在虚拟环境中以pip安装的形式运行此命令时,您的import语句在python脚本中可以保持不变。无需将其更改为psycopg2二进制文件