在 ubuntu 20.04LTS 上安装 pygame 的问题



我在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('"'"'rn'"'"', '"'"'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

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

最新更新