Pygame on Jetson nano

Did someone successfully installed and used pygame library of python in the Jetson Nano? and how did you did it, if you have a tutorial i will really appreciate that


Suppose you can build it from source with the instructions shared below:

May other developers help to share experiecnes.


yeah i follow the instructions but i got this error

running build
running build_py
copying src_py/ → build/lib.linux-aarch64-3.6/pygame
running build_ext
building ‘’ extension
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL2 -Isrc_c -I/usr/include/python3.6m -c src_c/_sdl2/video.c -o build/temp.linux-aarch64-3.6/src_c/_sdl2/video.o
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL2 -Isrc_c -I/usr/include/python3.6m -c src_c/pgcompat.c -o build/temp.linux-aarch64-3.6/src_c/pgcompat.o
src_c/pgcompat.c:52:1: error: expected identifier or ‘(’ before ‘{’ token

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

error: command ‘aarch64-linux-gnu-gcc’ failed with exit status 1


Instead of building it from the source, would you mind trying the pip3 installation?

$ python3 -m pip install pygame==2.0.0

You can find an experiment sharing on JetPack 4.5.1 below:


Hello how do we install pygame on Jetson AGX with jetpack4.6, is it the same way or a different way than this @AastaLLL @ShaneCCC

This is the error I am getting even after following this and installing these packages

sudo apt-get install python3-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-dev libsmpeg-dev python3-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev libfreetype6-dev

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 "<string>", line 1, in <module>
  File "/tmp/pip-build-8fwavmxl/pygame/", line 318, in <module>
  File "/tmp/pip-build-8fwavmxl/pygame/buildconfig/", line 221, in main
    deps = CFG.main(**kwds)
  File "/tmp/pip-build-8fwavmxl/pygame/buildconfig/", line 194, in main
    DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']),
  File "/tmp/pip-build-8fwavmxl/pygame/buildconfig/", line 39, in __init__
    self.ver = config[0].strip()
IndexError: list index out of range

Hunting dependencies...

For help with compilation see:
To contribute to pygame development see:

for the correct installation you just need the SDL2 packages that are missing

sudo apt-get install libsdl2-ttf-dev

sudo apt-get install libsdl2-image-dev

sudo apt-get install libsdl2-mixer-dev

normally are just those

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.