【问题标题】:psycopg2-binary installation into a virtual environment fails when trying to compile source code尝试编译源代码时,将 psycopg2-binary 安装到虚拟环境中失败
【发布时间】:2021-12-28 17:23:00
【问题描述】:

我正在尝试将psycopg2-binary 安装到我的 Django 项目中。我正在使用虚拟环境,我正在运行的命令是

pip 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.

但是,嘿,我正在安装 'psycopg2-binary'

为什么我会弄得这么乱?

【问题讨论】:

  • 平台/处理器架构?操作系统? Python版本? Python 是 32 位还是 64 位? (请注意,在 64 位操作系统上运行 32 位 Python 是可能的。)
  • macOS、M1、Python 3.8,不知道如何判断是 32 位还是 64 位
  • 我现在从 python.org 安装了 Python 3.10,它是 64 位的。尝试再次安装 psycopg2-binary,结果相同。

标签: django pip psycopg2


【解决方案1】:

Pip 在https://pypi.org/project/psycopg2-binary/2.9.2/#files 找不到您的处理器+操作系统,因此它尝试从源安装(页面上的最后一个文件)但失败了。

从源代码编译是目前唯一的方法。如果您可以向 Psycopg2 作者捐赠一些空闲的处理器周期,他们也许可以开始在 M1 上为 OSX 编译和发布轮子。

【讨论】:

  • 太好了,谢谢,这对我来说很有意义。
猜你喜欢
  • 2015-03-12
  • 1970-01-01
  • 2018-11-01
  • 2018-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多