Pygame package error when installing arducopter tools '' on RPi 4 running ubuntu 20.04

The error message log is below:

Collecting pygame
Using cached pygame-2.1.2.tar.gz (10.1 MB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-v1q2ib17/pygame/’"’"’; file=’"’"’/tmp/pip-install-v1q2ib17/pygame/’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ egg_info --egg-base /tmp/pip-install-v1q2ib17/pygame/pip-egg-info
cwd: /tmp/pip-install-v1q2ib17/pygame/
Complete output (29 lines):
WARNING, No “Setup” File Exists, Running “buildconfig/”
Using UNIX configuration…
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-v1q2ib17/pygame/”, line 359, in
File “/tmp/pip-install-v1q2ib17/pygame/buildconfig/”, line 225, in main
deps = CFG.main(**kwds)
File “/tmp/pip-install-v1q2ib17/pygame/buildconfig/”, line 188, in main
DependencyProg(‘SDL’, ‘SDL_CONFIG’, ‘sdl2-config’, ‘2.0’, [‘sdl’]),
File “/tmp/pip-install-v1q2ib17/pygame/buildconfig/”, line 39, in init
self.ver = config[0].strip()
IndexError: list index out of range
Hunting dependencies…

For help with compilation see:
Compilation - pygame wiki
To contribute to pygame development see:
Contribute - pygame wiki

ERROR: Command errored out with exit status 1: python egg_info Check the logs for full command output.

In general, for this type of problems it is better to check pip modules first:
pip list --outdated
and try to have an updated system.

pip install --upgrade pygame

Is there a special reason to build software from source on RPi?
Why not download the arm binary?

If I do this command I get the same error. Basically, pygame latest version isn’t compatible with RPi’s version.

I’ll give that a try. Thanks. I actually found a workaround that is similar to what you suggested and manually added the files which had issues and then followed this link to build ardupilot/ at master · ArduPilot/ardupilot · GitHub.

On a RPi4 here:
$ pip list|grep pygame
pygame 2.1.2
$ cat /etc/os-release
PRETTY_NAME=“Raspbian GNU/Linux 11 (bullseye)”