首页 > 解决方案 > 无法安装pygame

问题描述

我试图通过使用命令来安装 python-packages pip3 install pygame。我在 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

任何帮助,将不胜感激!

标签: pythonpippygame

解决方案


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

安装到 Ubuntu/Debian/Mint;

sudo apt-get install python3-pygame

安装到 Fedora/Red hat;

sudo yum install python3-pygame

推荐阅读