Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to install pygame using pip in a virtualenv. I'm following this tutorial on using Kivy. However, running pip install pygame returns

Downloading/unpacking pygame
Downloading pygame-1.9.1release.tar.gz (2.1MB): 2.1MB downloaded
Running egg_info for package pygame

WARNING, No "Setup" File Exists, Running ""
Using UNIX configuration...

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

Hunting dependencies...
WARNING: "sdl-config" failed!
WARNING: "smpeg-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
No files/directories in /tmp/pip-build-root/pygame/pip-egg-info (from PKG-INFO)
Storing complete log in /home/david/.pip/pip.log

The content of /home/david/.pip/pip.log can be found at

What am I doing wrong? I'm trying to keep to the standard methodology for installing pygame as much as possible in order to avoid deviating from the tutorial.

share|improve this question
up vote 9 down vote accepted

Try installing the dependencies:

sudo apt-get build-dep python-pygame
sudo apt-get install python-dev

How do I install Pygame in virtualenv?

share|improve this answer
After following the instructions in the link, pip install pygame now returns a new error message: – David Y. Stephenson Jun 26 '13 at 14:31
I updated it for now. – wojox Jun 28 '13 at 1:48

While wojox answer (from 2013) is correct, I had a difference experience (and solution) that I thought I would share in case someone else comes across this same problem.

I was able to install python-dev without hassle, but I was unable to build-dep python-pygame.

I kept getting:

genUser@mypc:~/downloads/RegExExpress$ sudo apt-get build-dep python-pygame
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: You must put some 'source' URIs in your sources.list

To solve this, I had to go into /etc/apt/sources.list and un-comment the lines in my source that were for deb-src. Example:

## Compatible with Debian Wheezy, but use at your own risk.
deb waldorf main
#deb-src waldorf main

deb wheezy main contrib non-free
#deb-src wheezy main contrib non-free

deb wheezy/updates main
#deb-src wheezy/updates main

(Any line that you see that has #deb-src needs to be uncommented (aka remove the # from the beginning).

If you do not have the src repo in your sources file (i.e. you don't see these lines or something similar in your sources.list file) then you'll have to find the correct src's distro to add; normally you can just add -src to whatever distro's you have listed in your sources.list file and you should be set!

NB: I don't expect that the correct answer will change (nor do I really care =P), but I thought others would want to know that some distros (like in my case: Crunchbang) could be blocking this solution because of these commented lines.

Good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.