17

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.
user2918138
  • 171
  • 1
  • 1
  • 3

6 Answers6

47

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
MoxyOron
  • 3
  • 1
EakzIT
  • 602
  • 5
  • 8
  • 2
    +1, this simple solution will be useful for many even if I had to install more than 100 MB of additional packages just for the "Alien Invasion" project... – GTK 1.2.6 fanboy Jun 13 '20 at 22:06
  • 2
    Finally! I tried every other answer and nothing worked. This finally worked. thank you – Corpse Jul 29 '20 at 16:57
  • 1
    @GTK1.2.6fanboy better be prepared for the invasion than scrambling to install those extra MB in a rush as it happens, I guess :) – matanster Feb 19 '22 at 11:17
11

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!! =)

icedwater
  • 4,701
  • 3
  • 35
  • 50
Eight Nice
  • 111
  • 1
  • 4
5

ORIGINAL: 2013.10.25

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

PySDL2 use SDL2


EDIT: 2021.10.17

Question and my original answer is almost 8 years old and it seems author removed PySDL2 from URL in my old answer. He moved code from bitbucket to github

Using Google I found

And meanwhile PyGame started to use SDL2.

See also all releases

furas
  • 134,197
  • 12
  • 106
  • 148
  • PySDL2 returns 404 – moudrick Oct 17 '21 at 20:09
  • @moudrick this answer is 8 years old. It seems author removed `PySDL2` from this URL. But if you use Google then you should find new place. https://pysdl2.readthedocs.io/en/rel_0_9_7/. BTW: as I know current `PyGame` uses `SDL2` – furas Oct 17 '21 at 20:37
2

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
Jay Shenawy
  • 953
  • 1
  • 12
  • 22
2

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
cnux9
  • 46
  • 3
2

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

Techno021
  • 41
  • 6
Lorin
  • 31
  • 4