我想在我的Django项目中使用postgresql,为此我需要在我的virtualenv中安装psycopg2。我已经安装了Postgresql 12.2。但是,当我运行pip install psycopg2
时,我得到了以下错误:
Error: pg_config executable not found.
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>).
我已经在/Library/PostgreSQL/12/bin/pg_config
找到了pg_config可执行文件,但是当我尝试使用PATH="/Library/PostgreSQL/12/bin/pg_config:$PATH"
将其添加到PATH变量时,没有显示成功或错误消息。我以前从未使用过PATH变量,所以我不确定我是否正确地这样做。当我随后尝试运行which pg_config
时,它仍然显示“pg_config未找到”,当我再次尝试安装psycopg2时,它显示相同的错误消息。
有人能帮我解决这个问题吗?
1条答案
按热度按时间w9apscun1#
两个选项
1.使用brew安装POSTGRESQL:
brew安装后gresql
1.在python虚拟环境中安装
psycopg2-binary
pip安装psycopg 2-二进制