I have a clean and updated raspbian stretch on rpi 3B+.

I created a virtual environment. Activated it. Compiled python 3.7 in the venv. Installed pyephem into it with pip.

All is working fine in the venv with python 3.7. Now I want to install pygame into this venv to add pygame functionality to my python 3.7 pyephem scripts.

I read elsewhere to first do this:

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

I am concerned that this will corrupt my clean python 3.7 compiled install. I could find no assurance that this would be a compatible solution for any and every current python version as well as versions that might be released tomorrow. So, trying to jump right in with a pip install of pygame, without first using those two lines above ...

pygame install failed with sdl-config missing

Then I installed and used apt-file search "sdl-config" to find its dependencies and install them ...

(venv) $ sudo apt install libsdl1.2-dev

that resolved the first problem of the missing sdl-config, but now...

"pkg-config freetype2" failed

(venv) $ apt-file search "freetype2"

decided libfreetype6-dev was most thorough dependency.

 (venv) $ sudo apt install libfreetype6-dev

it is already the newest version.

How do I get past this and proceed to get pygame installed into my venv that has python 3.7.0 and pyephem working perfectly already? And those two commands mentioned earlier, are they for both python3.x and python2.7, and how would one find out the known compatability and incompatibility with particular python and system versions?

if it helps, here is the complete output from the install pygame attempt...

(venv) $ python3 -m pip install pygame  
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pygame
  Using cached https://files.pythonhosted.org/packages/b2/6b/c510f0853765eb2219ca5aa3d416d65bb0dea7cd9bb2984aea0a0e04c24d/pygame-1.9.4.tar.gz

Complete output from command python setup.py egg_info:

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

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

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-5pfb91tx/pygame/
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.  

(venv) $ 

I intentionally left out the details of my terminal prompt.

Thank you for any insight into resolving this present difficulty.

1 Answer 1


This 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

Taken from https://stackoverflow.com/questions/7652385/where-can-i-find-and-install-the-dependencies-for-pygame

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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