Pygame在Windows 10上使用pip install pygame失败

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

我在安装python时遇到Pygame失败。我尝试了多种工作但没有成功。包括使用与PiP相同的不同选项路径模式重新安装python,包括升级和路径选项。

我现在想做什么?

Python 3.8.0a1 (tags/v3.8.0a1:e75eeb00b5, Feb  3 2019, 19:46:54) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
C:\Users\brog\Downloads>pip install pygame
Collecting pygame
  Using cached https://files.pythonhosted.org/packages/b2/6b/c510f0853765eb2219ca5aa3d416d65bb0dea7cd9bb2984aea0a0e04c24d/pygame-1.9.4.tar.gz
    Complete output from command python setup.py egg_info:


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

    Path for SDL not found.
    Too bad that is a requirement! Hand-fix the "Setup"
    Path for FONT not found.
    Path for IMAGE not found.
    Path for MIXER not found.
    Path for PNG not found.
    Path for JPEG not found.
    Path for PORTMIDI not found.
    Path for COPYLIB_tiff not found.
    Path for COPYLIB_z not found.
    Path for COPYLIB_vorbis not found.
    Path for COPYLIB_ogg not found.

    If you get compiler errors during install, doublecheck
    the compiler flags in the "Setup" file.


    Continuing With "setup.py"
    Error with the "Setup" file,
    perhaps make a clean copy from "Setup.in".
    ---
    For help with compilation see:
        https://www.pygame.org/wiki/CompileWindows
    To contribute to pygame development see:
        https://www.pygame.org/contribute.html
    ---
    C:\Users\brog\AppData\Local\Temp\pip-install-3177swfa\pygame\setup.py:321: SyntaxWarning: invalid escape sequence \d
      return ', '.join(s for s in findall('\d+', ver)[0:3])
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\brog\AppData\Local\Temp\pip-install-3177swfa\pygame\setup.py", line 203, in <module>
        extensions = read_setup_file('Setup')
      File "c:\users\brog\appdata\local\programs\python\python38-32\lib\distutils\extension.py", line 171, in read_setup_file
        line = expand_makefile_vars(line, vars)
      File "c:\users\brog\appdata\local\programs\python\python38-32\lib\distutils\sysconfig.py", line 405, in expand_makefile_vars
        s = s[0:beg] + vars.get(m.group(1)) + s[end:]
    TypeError: can only concatenate str (not "NoneType") to str

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\brog\AppData\Local\Temp\pip-install-3177swfa\pygame\

C:\Users\brog\Downloads>
python pip pygame windows-10 python-3.8
1个回答
4
投票

您正在使用仍在开发中的Python 3.8。因此,PyPI(https://pypi.org/project/Pygame/#files)上的包没有预先构建的“轮子”,所以pip正在尝试从源代码构建。从源代码构建可能是一个复杂的过程,因为您必须确保提供合适的编译器和所有非Python依赖项。这里有从源代码构建的说明:https://www.pygame.org/wiki/CompileWindows但请记住,如果构建过程出现问题,您可能很难找到帮助,因为您正在使用Python的开发版本。

我会说你的选择是:

  • 如果可以,请使用Python 3.7。安装pygame应该会容易得多。
  • 坚持使用Python 3.8并遵循以下说明:https://www.pygame.org/wiki/CompileWindows如果事情仍然失败,请尝试询问更具体的问题,解释您遵循的说明的哪些步骤。
© www.soinside.com 2019 - 2024. All rights reserved.