在 ubuntu 20.04LTS 上安装 pygame 时出现问题

Problem to install pygame on ubuntu 20.04LTS

我正在使用 Ubuntu 20.04LTS,我尝试为学校项目安装 pygame(对于 python)。但是当我尝试这个时:

sudo pip3 install pygame

我收到一个错误:

ERROR: Command errored out with exit status 1:
 command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-szdn6q_u/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-szdn6q_u/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-pip-egg-info-3fqnujta
     cwd: /tmp/pip-install-szdn6q_u/pygame/
Complete output (18 lines):


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


Hunting dependencies...
SDL     : found 1.2.15
FONT    : not found
IMAGE   : not found
MIXER   : not found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: not found
PORTTIME: not found
FREETYPE: found 23.1.17
Missing dependencies
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

你能帮帮我吗?

尝试使用

安装它
sudo apt install python3-pygame

相反。您收到的错误是因为您缺少 Pygame 依赖项,apt 应该为您安装这些依赖项。

一般来说,通过包管理器安装 Python 包是个好主意,只有当它们在那里不可用时才使用 pip。

尝试这样安装:

python3 -m pip install pygame==1.9.5rc2

我遇到了同样的问题,但效果很好。