8

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 setup.py egg_info for package pygame

WARNING, No "Setup" File Exists, Running "config.py"
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 http://paste.ubuntu.com/5800296/

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.

3 Answers 3

11

Try installing the dependencies:

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

How do I install Pygame in virtualenv?

2
2

This worked for me:

https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=33157

sudo apt-get install mercurial 
hg clone https://bitbucket.org/pygame/pygame
cd pygame

sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 
sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
sudo apt-get install python3-dev python3-numpy

python3 setup.py build 
sudo python3 setup.py install
3
  • Did it work for you on Ubuntu? The post mentions Raspbian... Also, I'm not sure this answers the question which is explicitly about installing pygame with pip in a virtualenv... can you explain why this is a good alternative?
    – Zanna
    Sep 16, 2017 at 20:12
  • Yes, it worked for me on Ubuntu. Pygame was unable to be called. I got errors like : /bin/sh: 1: freetype-config: not found. I do hope op tries the solution.
    – jouell
    Sep 18, 2017 at 1:32
  • use sudo apt-get install libfreetype6-dev to fix that @jouell Feb 10, 2018 at 21:22
1

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:

## CRUNCHBANG
## Compatible with Debian Wheezy, but use at your own risk.
deb http://packages.crunchbang.org/waldorf waldorf main
#deb-src http://packages.crunchbang.org/waldorf waldorf main

## DEBIAN
deb http://http.debian.net/debian wheezy main contrib non-free
#deb-src http://http.debian.net/debian wheezy main contrib non-free

## DEBIAN SECURITY
deb http://security.debian.org/ wheezy/updates main
#deb-src http://security.debian.org/ 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.

Don't forget to do a sudo apt-get update after updating the sources list.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .