Install Pygame on Jetson nano?

I tried to install PyGame on jetson nano, even though I spent hours on it, it failed :
1.

sudo apt-get install python3-pygame

failed due to the package is not included in the os.
2.

pip install pygame --user

failed as well.

Thanks

What’s the error show when install.

Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c β€˜import sys, setuptools, tokenize; sys.argv[0] = β€˜"’"’/tmp/pip-install-k4jvmk9f/pygame/setup.pyβ€™β€œ'β€β€˜; file=β€™β€œ'β€β€˜/tmp/pip-install-k4jvmk9f/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 pip-egg-info
cwd: /tmp/pip-install-k4jvmk9f/pygame/
Complete output (12 lines):

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

/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found

Hunting dependencies...
WARNING: "sdl-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
----------------------------------------

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

You need to install libsdl1.2-dev for sdl-config error

sudo apt install libsdl1.2-dev

Thanks! new error now…

ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c β€˜import sys, setuptools, tokenize; sys.argv[0] = β€˜"’"’/tmp/pip-install-54qtayvc/pygame/setup.pyβ€™β€œ'β€β€˜; file=β€™β€œ'β€β€˜/tmp/pip-install-54qtayvc/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 pip-egg-info
cwd: /tmp/pip-install-54qtayvc/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 21.0.15
Missing dependencies
----------------------------------------

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

sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev

5 Likes

This helped a lot. But I needed one more lib:
sudo apt-get install libfreetype6-dev

2 Likes

thanks for this, was very helpfull

For them who might find it interesting, some updates to install pygame 2.0.0 on Jetpack 4.5.1, Python3 on Jetson Nano:

  1. 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
  2. python3 -m pip install pygame==2.0.0

An β€˜import pygame’ is executed successfully.
regards, Peter

1 Like

Unfortunately the victory was too early:
β€œpygame.error: No available video device”
on line β€œself.display = pygame.display.set_mode((self.w, self.h))”. Any suggestions?