poetry 无法在 python 3.12 (macos) 中安装 psycopg2-binary

问题描述 投票:0回答:1

我无法在 python3.12 中通过诗歌安装

psycopg2-binary
包。


pyproject.toml

[tool.poetry]
name = "my_project"

[tool.poetry.dependencies]
psycopg2-binary = "*"

[build-system]
requires = ["poetry-core>=1.8.1"]
build-backend = "poetry.core.masonry.api"

在 python 3.11 中安装项目是可行的。

psycopg2-binary
安装。

当我尝试在python 3.12环境中安装poetry时,出现以下错误:

poetry install --with dev --sync
Installing dependencies from lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing psycopg2-binary (2.9.9): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel
  
  running egg_info
  writing psycopg2_binary.egg-info/PKG-INFO
  writing dependency_links to psycopg2_binary.egg-info/dependency_links.txt
  writing top-level names to psycopg2_binary.egg-info/top_level.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>).
  
  

  at ~/.pyenv/versions/3.12.0/envs/poetry312/lib/python3.12/site-packages/poetry/installation/chef.py:166 in _prepare
      162│ 
      163│                 error = ChefBuildError("\n\n".join(message_parts))
      164│ 
      165│             if error is not None:
    → 166│                 raise error from None
      167│ 
      168│             return path
      169│ 
      170│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with psycopg2-binary (2.9.9) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"'.

令我困惑的是,该错误看起来像是在尝试安装

pyscopg2
,而不是
psycopg2-binary

我不完全理解底部的注释。

注意:此错误源自构建后端,可能不是诗歌的问题,而是 psycopg2-binary (2.9.9) 不支持 PEP 517 构建的问题。您可以通过运行“pip wheel --no-cache-dir --use-pep517“psycopg2-binary (==2.9.9)”'来验证这一点。

当我执行

pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"
时,返回以下内容:

$ pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"
Collecting psycopg2-binary==2.9.9
  Downloading psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl.metadata (4.4 kB)
Downloading psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl (2.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 MB 2.4 MB/s eta 0:00:00
Saved ./psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl

我不明白这验证了什么......

此外,我可以通过 pip 安装

psycopg2-binary


  • MacOS 14(索诺玛)M2
  • 诗歌1.7.0
python macos psycopg2 python-poetry
1个回答
0
投票

嗯,这似乎是某种诗歌缓存问题。

我跑了这个:

poetry cache clear . --all

然后就可以安装

psycopg2-binary
就好了。

© www.soinside.com 2019 - 2024. All rights reserved.