9
votes

I used

./configure --prefix=$HOME
make
make install

to install sdl2, after which I tried to install pygame by

cd ../pygame-1.9.1release/
python setup.py install

but I am getting an error:

linuxnx:~/python/library/pygame-1.9.1release> python setup.py install
WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...
Hunting dependencies...
sh: sdl-config: command not found
WARNING: "sdl-config" failed!
sh: smpeg-config: command not found
WARNING: "smpeg-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
6
If you install using pip, you shouldn't have to mess with installing SDL manually. - ninMonkey
Not true, actually. I ran into this error from a pip3 install tensor2tensor. - icedwater

6 Answers

37
votes

I searched a long time, cause I needed the package for Python Crash Course by Eric Matthes, but couldn't find the answer that would help running pip install pygame without errors and finally found 1 line solution that worked for me

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 libfreetype6-dev
11
votes

I'm seeing that this thread has been around for a long time, but I think it's a good idea to leave this here in case it helps someone. I found these lines on a website that might help:

At the moment, 5/1/2020, you cannot install the pygame libraries in python 3.8 with pip install pygame, bu you can install them with a particular version of them, still for dev. You can install Python 3.8 in the command line using this version: pip install pygame==2.0.0.dev6 Latest version: pip install pygame==2.0.0.dev10

I don't know if you use python3 but it throws me more errors apart from sdl as well as freetype-config ... Before I used "python3 -m pip install pygame".

:~$ python3 -m pip install pygame==2.0.0.dev10
Collecting pygame==2.0.0.dev10
  Downloading pygame-2.0.0.dev10-cp38-cp38-manylinux1_x86_64.whl (14.3 MB)
     |████████████████████████████████| 14.3 MB 130 kB/s
Installing collected packages: pygame
Successfully installed pygame-2.0.0.dev10

Nice programming time for all!! =)

3
votes

PyGame-1.9.1 was created in 2009 so it still use old SDL 1.2 not new SDL2.

PySDL2 use SDL2

2
votes

Try this in the terminal , It should installs the sdl 1.2 # make a temporary directory where we can download and build stuff

mkdir tmp
cd tmp

# download and install SDL
wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
tar -xzvf SDL-1.2.14.tar.gz
cd SDL-1.2.14
./configure 
sudo make all
2
votes

After I read top answer above,

I installed python-dev, libsdl-image1.2-dev.

Then I got

Hunting dependencies...
WARNING: "pkg-config freetype2" failed!
WARNING: "freetype-config" failed!
SDL     : found 1.2.15
FONT    : not found
IMAGE   : found
MIXER   : not found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: not found
PORTTIME: not found
FREETYPE: not found
Missing dependencies

So I just installed these and it worked.

sudo apt install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libportmidi-dev libfreetype6-dev
1
votes

This error showed up once again in Pygame-2.0.0.dev12

The solution for me was:

sudo apt-get install libsdl2-dev

Then I got

Hunting dependencies...
SDL     : found 2.0.9
FONT    : not found
IMAGE   : not found
MIXER   : not found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
FREETYPE: found 22.1.16

So I ran this command below:

sudo apt-get install libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev

To wrap up the missing dependencies