【问题标题】:Can't install psycopg2-binary无法安装 psycopg2-binary
【发布时间】:2021-11-06 19:59:19
【问题描述】:

我正在尝试在预装 Postgresql 12 的 Centos 7 上的 Django 项目的虚拟环境中安装 psycopg2-binary (pip3 install psycopg2-binary),但出现了众所周知的错误:

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.

我尝试安装python3-devel postgresql-libs postgresql-server postgresql-devel postgresql-contrib,但还是出现这个错误。

pip3 install psycopg2, pip install psycopg2 - 同样的问题。

PS 通过更新 pip (pip install --upgrade pip) 解决了问题。

【问题讨论】:

  • 你的机器上安装并运行了 postgres 吗?
  • 是的,已安装 postgress。但我是一个慢吞吞的 )) 我使用的是旧版本的 pip。只需 pip install --upgrade pip 一切都开始正常工作了。
  • stackoverflow.com/questions/11618898/… 这包含可能的解决方案

标签: django centos psycopg2


【解决方案1】:

你可以试试这个方法,很有用

sudo apt-get install postgresql postgresql-dev python-dev

【讨论】:

    猜你喜欢
    • 2021-04-06
    • 1970-01-01
    • 2022-01-04
    • 1970-01-01
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 2017-12-05
    相关资源
    最近更新 更多