23

Can't quite figure out how to install PyGame in a virtualenv on OSX Lion. I'd really like to keep things contained in the virtualenv, if at all possible.

I've tried downloading the source for PyGame and running the included setup.py in the virtualenv, but it seems to be having a bunch of issues finding the SDL requirements even after installing those via Homebrew.

Any tips from someone that's set this up?

Flimm
  • 136,138
  • 45
  • 251
  • 267
notanumber
  • 6,399
  • 3
  • 20
  • 32
  • I've got it working and setup without any issues on Debian. I don't have or use OSX. What error messages are you seeing? – Noufal Ibrahim Dec 10 '11 at 18:41
  • did you do https://bitbucket.org/pygame/pygame/issue/82/homebrew-on-leopard-fails-to-install#comment-627494 – dm03514 Dec 10 '11 at 20:05

1 Answers1

32

Yes, you can use it in 3 steps with brew:

brew install python
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi 
/usr/local/share/python/pip install hg+http://bitbucket.org/pygame/pygame

(this is how i did it, it's working perfectly.)

If you don't know brew, start here

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
tito
  • 12,990
  • 1
  • 55
  • 75
  • 2
    Interesting. The above worked, although I used the virtualenv's pip instead of he one in /usr/local/share/python. Not sure if that makes a difference or not. I'm not clear as to why I need to use a separately hosted pygame though (i.e., http://bitbucket.org/pygame). Shouldn't the "official" one work? If not, why haven't the PyGame folks fixed this? – notanumber Dec 10 '11 at 22:57
  • 1
    Probably because pygame requires other non python or pip-manageable libraries to be installed on the target machine - it is a bit more involved than a web lib - using sdl (an open source, cross platform equivalent of DirectX) for fast access to native framebuffers/card hardware or sound resources. The last step with the pip install using your virtual env's version is critical. – Danny Staple Jul 31 '12 at 19:08
  • 1
    Please note: If you want to install PyGame to the virtualenv's `site-packages`, you'll have to setup the `virtualenv` using `--system-site-packages`. Then you can just use `pip install ...` instead of `/usr/local/share/python/pip install` and PyGame will be installed locally. – Ory Band Sep 04 '12 at 21:31
  • To get smpeg, see [this](http://stackoverflow.com/questions/19614518/homebrew-no-formula-for-smpeg) – jgritty Aug 15 '14 at 20:33