python - 通过pip安装pygame报错

标签 python pygame pip command-prompt

我正在尝试安装 pygame 以通过 pip 使用 python,但是当我使用命令 pip install pygame 时,它​​开始工作并且看起来没问题,直到它抛出错误。这是我得到的输出,我不确定我是否做得正确或者什么,我是 pip 新手,所以我不确定。任何帮助将不胜感激!

C:\Users\Matthew>pip install pygame
Collecting pygame
  Using cached pygame-1.9.2.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".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Matthew\AppData\Local\Temp\pip-build-kzk4_t2_\pygame\setup.
py", line 165, in <module>
        extensions = read_setup_file('Setup')
      File "c:\users\matthew\appdata\local\programs\python\python36-32\lib\distu
tils\extension.py", line 171, in read_setup_file
        line = expand_makefile_vars(line, vars)
      File "c:\users\matthew\appdata\local\programs\python\python36-32\lib\distu
tils\sysconfig.py", line 410, in expand_makefile_vars
        s = s[0:beg] + vars.get(m.group(1)) + s[end:]
    TypeError: must be str, not NoneType

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Matthew\
AppData\Local\Temp\pip-build-kzk4_t2_\pygame\

最佳答案

这是一个老问题,但该错误通常与 Python 和 PyGame 版本不兼容有关。您应该检查您使用的 Python 版本是否与 PyGame 版本兼容。

您可能需要安装特定版本的 PyGame,例如python -m pip install pygame==1.9.3

我一直在使用 PyGame 1.9.3 和 Python 3.6.8,并且运行良好

关于python - 通过pip安装pygame报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41339661/

相关文章:

python - Windows 上的 Pypy 和 Pillow?

python - 找不到 Pip 命令。路径问题

javascript - 将数据从 Python 返回到 Javascript

python - python 中每个日志级别的适当使用的文档

python - 如何使用 Tiled 和 pytmx 在 Pygame 中显示平铺 map ?

python - 如何在 Pygame 中的不同对象的事件中拥有多个计时器?

python - 将输入传递给 Popen 进程

javascript - python selenium 将键发送到只读文本框

python - Sprite 是如何工作的。 Sprite 碰撞?

python - 无法在我的 setup.py 上运行 bdist_wheel 构建命令