Python( Django ) pip install psycopg2 在 MacOS 中出错

Mas*_*ani 1 python django postgresql psycopg2

我为我的项目设置了 virtualenv 以及何时我想运行

pip 安装 psycopg2

我在下面收到错误

ERROR: Complete output from command python setup.py egg_info:
ERROR: running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

Error: pg_config executable not found.

pg_config is required to build psycopg2 from the 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
<http://initd.org/psycopg/docs/install.html>).
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/r5/mt37g42j2h3b676lpx3qlznm0000gn/T/pip-install-yijundiy/psycopg2/
Run Code Online (Sandbox Code Playgroud)

之后,我运行 brew install postgresql 然后当我想运行时:

pip install psycopg2 我收到这个错误:

Running setup.py install for psycopg2 ... error
      Running setup.py install for psycopg2 ... error
        ERROR: Complete output from command 
    ERROR: Command "/Users/masoudmk/Desktop/Masoud/projectenv/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/tmp/pip-install-6qi9xbe0/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-t8hmiffn/install-record.txt --single-version-externally-managed --compile --install-headers /Users/masoudmk/Desktop/Masoud/projectenv/bin/../include/site/python3.7/psycopg2" failed with error code 1 in /private/tmp/pip-install-6qi9xbe0/psycopg2/
Run Code Online (Sandbox Code Playgroud)

另外,当我使用这个命令时

须藤 python setup.py 安装

我也收到这个错误:

(null): can't open file 'setup.py': [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)

我该怎么办!?

小智 8

获得一个独立的包

pip install psycopg2-binary