2

I am operating on a Mac and using Enthought python I have installed PIP but am having difficulty installing packages.

When I attempt to install Pygame, the package is downloading and begins building but then errors. I realize that Pygame is a relatively complex package but I have similar same problem with simpler packages. Because I thought it may have to do with my installation of Python, I show my env variables at the end. Any help would be appreciated

the trace looks like:

running build_ext building 'pygame._numericsurfarray' extension creating build/temp.macosx-10.5-i386-2.7 creating build/temp.macosx-10.5-i386-2.7/src gcc -fno-strict-aliasing -fno-common -dynamic -arch i386 -DNDEBUG -g -O3 -arch i386 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/7.3/include/python2.7 -c src/_numericsurfarray.c -o build/temp.macosx-10.5-i386-2.7/src/_numericsurfarray.o In file included from src/_numericsurfarray.c:23: src/pygame.h:106:17: error: SDL.h: No such file or directory In file included from src/_numericsurfarray.c:23: src/pygame.h:350: error: expected specifier-qualifier-list before ‘SDL_VideoInfo’ src/pygame.h:388: error: expected specifier-qualifier-list before ‘SDL_Surface’ src/_numericsurfarray.c:26:27: error: SDL_byteorder.h: No such file or directory .... .... ... .... src/_numericsurfarray.c:1097: error: expected declaration specifiers or ‘...’ before ‘SDL_Surface’ error: command 'gcc' failed with exit status 1 

Command /Library/Frameworks/Python.framework/Versions/7.3/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/var/folders/9m/qcp8h8ss4ng1v8429jvnkkrc0000gn/T/pip-build/pygame/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9m/qcp8h8ss4ng1v8429jvnkkrc0000gn/T/pip-roxs9O-record/install-record.txt --single-version-externally-managed failed with error code 1 in /var/folders/9m/qcp8h8ss4ng1v8429jvnkkrc0000gn/T/pip-build/pygame Storing complete log in /Users/jc_macpro/.pip/pip.log 

my environment variables are:

TERM_PROGRAM=Apple_Terminal TERM=xterm-256color SHELL=/bin/bash TMPDIR=/var/folders/9m/qcp8h8ss4ng1v8429jvnkkrc0000gn/T/ Apple_PubSub_Socket_Render=/tmp/launch-iwuiuZ/Render TERM_PROGRAM_VERSION=309 TERM_SESSION_ID=FDC661E1-1196-448F-8D69-28AD9D7C496B USER=jc_macpro COMMAND_MODE=unix2003 SSH_AUTH_SOCK=/tmp/launch-pH83z9/Listeners __CF_USER_TEXT_ENCODING=0x1F5:0:0 Apple_Ubiquity_Message=/tmp/launch-s4tuBY/Apple_Ubiquity_Message PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin PWD=/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages LANG=en_US.UTF-8 SHLVL=1 HOME=/Users/jc_macpro LOGNAME=jc_macpro SECURITYSESSIONID=186a4 _=/usr/bin/env OLDPWD=/Library/Frameworks/Python.framework/Versions/Current/bin 

I would appreciate any help.

UPDATE: 12/22/12 I have sifted through al of the advice and feedback and appreciate it all very much. All efforts at installing the binaries on Enthought did not work. I did not want o add more complexity with Macports so I decided to blow out my Enthought python and simply work with the official Python 2.7. I am a huge fan of Enthought and it was a great way to provide a stable base from which to work when I started messing around with Python. However, as was pointed out it has some limitations.

With Python 2.7 as my default I reinstalled pip, added basic functionality and was then able to install the binaries necessary for pygame, numpy, matplotlib, and wxPython. So now I functioning and once again dangerous - just now with official Python 2.7!! Thank you all.

1
  • As a side note: I haven't used Enthought in a while, but /Library/Frameworks/Python.framework/Versions/7.3/ looks wrong. That ought to be 2.7 or 2.7.3, not 7.3, unless this is some weird thing they've deliberately done to avoid colliding with Python.org 2.7.3 or something. Commented Dec 21, 2012 at 23:00

2 Answers 2

4

You are missing a dependency, SDL.

If you have macports install, use that to install libsdl.

Or better still, download the Pygame binary for Mac; it includes the SDL library in the installer.

Sign up to request clarification or add additional context in comments.

11 Comments

I would not use MacPorts to install SDL, unless you also want to use MacPorts Python. If you're using Enthought, Apple, or python.org Python, it's usually much better to find a binary, use Homebrew, or build manually.
@abarnert: best would be to use the Pygame installer in this case. No idea what the OP is using or why they wanted to use pip though.
Yes, as long as that works with Enthought Python. Having not checked that, I don't know if it will work.
@Martijn To be fair, having a single package manager to install everything is much nicer than having to look for binary files all over the internet. If there is a pip package I'd generally try that one first too.
@Voo: But there's not going to be a pip package for SDL, because it's not a Python library. Homebrew, unlike MacPorts, is designed to work well with any Python installation you want, and its pip, but it's not prefect.
|
3

The problem is that you need SDL to install PyGame. You may also want to install various SDL add-on packages (SDL_ttf for fonts, etc.) as well.

As Martijn Pieters suggests, Pygame comes with a binary installer for Mac. I have no idea whether it will work with Enthought Python, but I'd try that first.

If it fails, SDL also has a binary installer for Mac. Again, I don't know if it will work for you, but I'd try it next.

If that fails, I'd use Homebrew. Homebrew (unlike MacPorts and Fink) is designed to work well with any Python installation you want to use, and with that Python's pip. (See here and here for details.) So, type brew search sdl to get a list of all of the add-on packages, and then brew install sdl sdl_foo sdl_bar etc. to install them.

For your additional problem, that you can't pip install anything because of permissions errors in '/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/`, that's an easy one: You don't have permission to write to that directory. There are two ways to fix it:

  1. Use sudo pip install foo instead of pip install foo.
  2. Use sudo chmod -R a+w /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/ to give yourself write access, so you can pip install foo. (You may need to add a few other directories.)

The second one is very much in the spirit of Homebrew (see the two links above, which go into more detail on how and why to do this), and it works great with python.org packages because many people are using it that way regularly, but I can't guarantee that it's a good idea with Enthought packages, while I can guarantee the first one.

3 Comments

OK. First things, first. Thank You. The sudo pip install yolk worked perfectly. As for pygame, on my desktop mac i installed pip and then pip installed pygame flawlessly. all with 32 bit Enthought so something is weird. I use Enthought simply because I am a noob and direct compiling scares the heck out of me. Sounds like I have to get over it and dive in. I'll read about homebrew. in the meantime, I'll try as you suggest on pygame. Thanks so much!
@NewatPython: On your desktop Mac, you must have already had SDL somehow. The pygame installer is supposed to bail out earlier than it did when it fails to find SDL, but it isn't supposed to work, because there's no way it could. (If you can remember what you did on the desktop, presumably the same thing will work here, but I'm guessing you can't.)
@NewatPython: Meanwhile, there's nothing wrong with using Enthought. numpy/scipy can be a pain to install yourself, even with Homebrew, especially if you want the full Fortran stuff. But it doesn't include everything in the world; you'll still occasionally need to learn to find and install prerequisites for other things, like SDL for pygame, or libxml2 for lxml, etc., whether you do it through binaries, through Homebrew, or through manual compilation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.