【问题标题】:Python( Django ) pip install psycopg2 error in MacOSMacOS中的Python(Django)pip安装psycopg2错误
【发布时间】:2019-10-11 04:00:14
【问题描述】:

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

pip install 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/

之后,我运行 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/

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

sudo python setup.py install

我也遇到这个错误:

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

我该怎么办!?

【问题讨论】:

标签: python django postgresql psycopg2


【解决方案1】:

获取独立包

运行pip install psycopg2-binary

【讨论】:

    【解决方案2】:

    我认为你没有安装 Postgres,你可以使用安装

    brew install postgresql
    

    这可以帮助您解决问题。之后就可以安装pip依赖包了

    【讨论】:

    猜你喜欢
    • 2012-07-17
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 2013-03-20
    • 1970-01-01
    • 2018-09-23
    • 2020-02-27
    相关资源
    最近更新 更多