I am on Ubuntu 20.04LTS, and I try to install pygame (for python) for a school project. But when I try this:
JavaScript
x
2
1
sudo pip3 install pygame
2
I received an error:
JavaScript
1
25
25
1
ERROR: Command errored out with exit status 1:
2
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
3
cwd: /tmp/pip-install-szdn6q_u/pygame/
4
Complete output (18 lines):
5
6
7
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
8
Using UNIX configuration
9
10
11
Hunting dependencies
12
SDL : found 1.2.15
13
FONT : not found
14
IMAGE : not found
15
MIXER : not found
16
PNG : found
17
JPEG : found
18
SCRAP : found
19
PORTMIDI: not found
20
PORTTIME: not found
21
FREETYPE: found 23.1.17
22
Missing dependencies
23
----------------------------------------
24
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
25
Can you help me, please?
Advertisement
Answer
Try installing it with
JavaScript
1
2
1
sudo apt install python3-pygame
2
instead. The error you are getting is because you are missing the Pygame dependencies, which apt should install for you.
As a general rule, it’s a good idea to install Python packages through the package manager, and use pip only if they’re unavailable there.