python - 无法安装pygame

标签 python pip pygame

<分区>

我尝试使用命令 pip3 install pygame 安装 python 包。我在 Ubuntu(linux) 上,这就是我使用 pip3 而不是 pip 的原因。但它返回以下错误

Collecting pygame
  Using cached pygame-1.9.6.tar.gz (3.2 MB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e71p_fru/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-e71p_fru/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 /tmp/pip-install-e71p_fru/pygame/pip-egg-info
         cwd: /tmp/pip-install-e71p_fru/pygame/
    Complete output (29 lines):


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

    /bin/sh: 1: sdl-config: not found
    /bin/sh: 1: sdl-config: not found
    /bin/sh: 1: sdl-config: not found
    Package freetype2 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    Package freetype2 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    Package freetype2 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    /bin/sh: 1: freetype-config: not found
    /bin/sh: 1: freetype-config: not found
    /bin/sh: 1: freetype-config: not found

    Hunting dependencies...
    WARNING: "sdl-config" failed!
    WARNING: "pkg-config freetype2" failed!
    WARNING: "freetype-config" failed!
    Unable to run "sdl-config". Please make sure a development version of SDL is installed.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

此外,对于 pygame 以外的任何包都不会发生这种情况。

我用的是python3.8,我用的是Ubuntu20.04

我们将不胜感激!

最佳答案

许多 Linux 发行版都有自己的 Pygame 包

安装到 Ubuntu/Debian/Mint;

sudo apt-get install python3-pygame

安装到 Fedora/Red hat;

sudo yum install python3-pygame

关于python - 无法安装pygame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61893077/

相关文章:

python - 如何让我的代码等待点击?

python - 用于查找 { } 内所有文本的正则表达式,包括空格和换行符

python - virtualenv 不包括 pip

python - 如何强制旧版本的 eog 在新实例中运行?

python - 如何查看安装的 pip 包大小?

python - 没有名为 googleapiclient.discovery 的模块

python - 为什么我的 pygame 应用程序循环不能正常工作?

python - 从文本文件读取字典将整数键转换为字符串 : Python

python - 更新tensorflow-gpu后,为什么仍然使用旧版本?

python - 敌人角色被游戏背景 overdraw