【问题标题】:Error while attempting to pip install psycopg2==2.7.*尝试 pip install psycopg2==2.7 时出错。*
【发布时间】:2020-12-11 16:50:44
【问题描述】:

我正在尝试在我的 PyCharm 终端上运行包 pip install psycopg2==2.7.*,以便部署我的网站,但我收到了下面显示的消息

Collecting psycopg2
  Using cached https://files.pythonhosted.org/packages/a8/8f/1c5690eebf148d1d1554fc00ccf9101e134636553dbb75bdfef4f85d7647/psycopg2-2.8.5.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /Users/applecare/PycharmProjects/learning_log/11_env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w6/sqx_mjh176x08sjppl82f1l80000gn/T/pip-install-8j8wbzsu/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/w6/sqx_mjh176x08sjppl82f1l80000gn/T/pip-install-8j8wbzsu/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /private/var/folders/w6/sqx_mjh176x08sjppl82f1l80000gn/T/pip-install-8j8wbzsu/psycopg2/
    Complete output (23 lines):
    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 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>).
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.2.2 is available.
You should consider upgrading via the '`pip install --upgrade pip`' command.

【问题讨论】:

  • 你的系统上安装了 postgresql 吗?

标签: django macos pycharm psycopg2 heroku-cli


【解决方案1】:

如果您在 Linux 上,您需要安装 PostgreSQL 来运行您的数据库,然后将客户端连接到您的 PostgreSQL 数据库,您将需要其他软件包,例如 libpq-devlibpq5

您可以使用以下命令安装上述软件包。

sudo apt-get install postgresql
sudo apt-get install libpq5
sudo apt-get install libpq-dev

【讨论】:

  • 拜托我用的是mac
【解决方案2】:

因此,如果您使用的是 Mac,我可以考虑两种方式:

  • pip install psycopg2-binary
  • 使用 brew 或优秀的 postgre.app 安装 PostgreSQL 并指向 pg_config 二进制文件的路径(这实际上是您遇到的错误)

【讨论】:

    【解决方案3】:

    在 Mac 上,我使用了 brew install postgresql,它为我解决了问题

    【讨论】:

      猜你喜欢
      • 2018-08-31
      • 2013-06-25
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      • 2020-09-01
      • 2016-04-07
      • 2021-08-01
      • 2013-04-01
      相关资源
      最近更新 更多