奇怪的是,我无法在 conda 环境中安装 pygame 用于 Python 中的游戏开发

I'm weirdly not able to install pygame in conda environment for game development in Python

我正在学习 Python 并已切换到 Anaconda,因为它提供了比普通版本更多的支持和预安装的库。正如我开始使用 pygame 一样,我在 Anaconda Prompt 中尝试安装它时遇到此错误:

conda install pygame
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - pygame

Current channels:

  - https://repo.anaconda.com/pkgs/main/win-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/win-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/msys2/win-64
  - https://repo.anaconda.com/pkgs/msys2/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

请帮助我访问 pygame,因为我的朋友在使用它时没有问题,我尝试重新安装,但即使那样也无济于事。

如果您按照错误消息中的建议到达 anaconda.org 并输入 pygame,则您会发现默认频道不可用。如果您想使用 conda 安装,唯一的选择是使用它可用的渠道之一,例如CogSci。因此,要为您的游戏开发创建一个环境,您可以这样做:

conda create -n pygame -c CogSci pygame

或者,如果您想安装到现有环境(请注意,建议为单独的项目使用单独的环境),那么您可以安装 pygame 和

conda install -c CogSci pygame

请注意,该频道中的版本已超过 5 年。另一种方法是您可以使用 pip:#

安装 pygame
pip install pygame