简体   繁体   English

如何在 Windows 10 中为 python 3.9 安装 pygame?

[英]How to install pygame in Windows 10 for python 3.9?

I have tried everything Here are some of the methods I have tried我已经尝试了一切这里是我尝试过的一些方法

  1. C:\\Users\\win 10\\AppData\\Local\\Programs\\Python\\Python39> python -m pip install pygame-1.9.6-cp27-cp27m-win_amd64.whl

The following error is prompted:提示如下错误:

ERROR: pygame-1.9.6-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.
  1. C:\\Users\\win 10\\AppData\\Local\\Programs\\Python\\Python39> pip install pygame

The following error is prompted:提示如下错误:

ERROR: Command errored out with exit status 1:
     command: 'c:\users\win 10\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\win 10\\AppData\\Local\\Temp\\pip-install-l782i464\\pygame\\setup.py'"'"';
__file__='"'"'C:\\Users\\win 10\\AppData\\Local\\Temp\\pip-install-l782i464\\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\win 10\AppData\Local\Temp\pip-pip-egg-info-1zl98t9z'
         cwd: C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\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\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\setup.py", line 194, in <module>
        buildconfig.config.main(AUTO_CONFIG)
      File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\buildconfig\config.py", line 210, in main
        deps = CFG.main(**kwds)
      File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\buildconfig\config_win.py", line 576, in main
        and download_win_prebuilt.ask(**download_kwargs):
      File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\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.

What should I do?我该怎么办?

您可以使用支持 Python 3.9.0 的预发布版本。

python3 -m pip install pygame --pre --user

Many packages do not have pre-built wheels for Python 3.9 as it is new.许多软件包没有为 Python 3.9 预先构建轮子,因为它是新的。

Also pygame-1.9.6-cp27-cp27m-win_amd64.whl is for Python 2.7 pygame-1.9.6-cp27-cp27m-win_amd64.whl 也适用于 Python 2.7

Your best bet is to revert to Python 3.8.6 to install pre-built wheel with pip最好的办法是恢复到 Python 3.8.6 以使用 pip 安装预构建的轮子

install pywin32 first ,pip install pywin32.首先安装pywin32,pip安装pywin32。 and then istall pygame pip install pygame by doing this you shall be able to download it然后通过执行此操作安装 pygame pip install pygame 您将能够下载它

This is the way i did it.这就是我这样做的方式。

Open command prompt on windows and type:在 Windows 上打开命令提示符并键入:

py -m pip install -U pygame --user

Then afterwards to test it out try this small game:然后再测试一下试试这个小游戏:

py -m pygame.examples.aliens

With reference to @ViaxCo answer at above for pre-release version installation, which could be for Linux/ macOS, below is another option for Windows, in case 'python3' causing "python was not found error" .参考上面@ViaxCo 对预发布版本安装的回答,这可能适用于 Linux/macOS,下面是 Windows 的另一个选项,以防 'python3' 导致"python was not found error" My installed python version is 3.9.6我安装的python版本是3.9.6

python -m pip install pygame --pre --user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM