Python 无法安装pygame

Python 无法安装pygame,python,pip,pygame,Python,Pip,Pygame,我试图使用命令pip3installpygame安装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, setuptoo

我试图使用命令
pip3installpygame
安装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
安装到软呢帽/红帽上

sudo yum install python3-pygame

试试这个
python3-m pip install-U pygame--user
@yagizcandegirmenci该命令给出了相同的错误。这个
sudo apt get install python3 pygame
能解决您的问题吗?@yagizcandegirmenci非常感谢您,这很有效。你现在可以写一个答案,这样我就可以接受了。