虽然通过pip安装pygame,但我不断收到错误消息

问题描述

我正在尝试使用pip在Windows 10上安装pygame。我正在使用python3。我在运行pip install pygame时始终收到此错误

Collecting pygame
  Using cached pygame-1.9.6.tar.gz (3.2 MB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\aarav\appdata\local\programs\python\python39\python.exe' -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'C:\\Users\\aarav\\AppData\\Local\\Temp\\pip-install-4b04m745\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\aarav\\AppData\\Local\\Temp\\pip-install-4b04m745\\pygame\\setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\aarav\AppData\Local\Temp\pip-pip-egg-info-up4741kz'
         cwd: C:\Users\aarav\AppData\Local\Temp\pip-install-4b04m745\pygame\
    Complete output (17 lines):


    WARNING,No "Setup" File Exists,Running "buildconfig/config.py"
    Using WINDOWS configuration...


    Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):
      File "<string>",line 1,in <module>
      File "C:\Users\aarav\AppData\Local\Temp\pip-install-4b04m745\pygame\setup.py",line 194,in <module>
        buildconfig.config.main(AUTO_CONfig)
      File "C:\Users\aarav\AppData\Local\Temp\pip-install-4b04m745\pygame\buildconfig\config.py",line 210,in main
        deps = CFG.main(**kwds)
      File "C:\Users\aarav\AppData\Local\Temp\pip-install-4b04m745\pygame\buildconfig\config_win.py",line 576,in main
        and download_win_prebuilt.ask(**download_kwargs):
      File "C:\Users\aarav\AppData\Local\Temp\pip-install-4b04m745\pygame\buildconfig\download_win_prebuilt.py",line 302,in ask
        reply = raw_input(
    EOFError: EOF when reading a line
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

有人对我如何解决此问题有建议吗?

解决方法

从错误日志中,您正在使用Python 3.9。当前的Pygame版本1.9.6并非support Python 3.9。您有几种选择:

  1. 安装并使用Python 3.8,然后pip install pygame应该可以工作。
  2. 安装Pygame 2开发版本pip install pygame==2.0.0.dev14pip install pygame --pre,以获取最新的预发行版本。
  3. 尝试使用Christoph Gohlke的第三方pygame wheel,他提供了针对cpython39的pygame 1.9.6。