使用 Poetry 和 Python 3.12 安装 pygame

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

我尝试使用 Python 3.12 安装 pygame 并使用 Poetry 来管理依赖项。

我运行了

poetry install
并收到以下错误:

...
    File "/Users/r_2009/Library/Caches/pypoetry/virtualenvs/coffeeshop-It7qMoV3-py3.12/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 111, in _find_eggs_in_dir
      from pip._vendor.pkg_resources import find_distributions
    File "/Users/r_2009/Library/Caches/pypoetry/virtualenvs/coffeeshop-It7qMoV3-py3.12/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2164, in <module>
      register_finder(pkgutil.ImpImporter, find_on_path)
                      ^^^^^^^^^^^^^^^^^^^
  AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
python-3.x pip python-poetry python-3.12
1个回答
0
投票

我可以通过将虚拟环境中的

pip
升级到最新版本来解决此问题。

虚拟环境是Poetry创建的,所以我进入了shell:

poetry shell

然后运行以下命令:

python -m ensurepip --upgrade

这将运行 ensurepip 模块的功能来升级已安装的 pip 版本。

运行后,我能够运行

poetry install
,没有错误。

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