0

Possible Duplicate:
How to use/install gcc on Mac OS X 10.8 / Xcode 4.4

I cannot install any Python packages using easy_insall or pip, because of the following error. I've looked everywhere, and seen several variations of this error, but have not found a solution that is easy to understand/follow. Any help is much appreciated!

I'm running on Mac OS 10.8.1

Python version 2.7.3

Xcode version 4.5.2 (with Command Line Tools installed)

...if you need any more information in order to figure out the problem, please ask!

$ easy_install pil
Searching for pil
Reading http://pypi.python.org/simple/pil/
Reading http://www.pythonware.com/products/pil
Reading http://effbot.org/zone/pil-changes-115.htm
Reading http://effbot.org/downloads/#Imaging
Best match: PIL 1.1.7
Downloading http://effbot.org/media/downloads/PIL-1.1.7.tar.gz
Processing PIL-1.1.7.tar.gz
Writing /var/folders/9q/bvqtzkbx1hg1934b36zgk0y40000gn/T/easy_install-wfZs_Y/PIL-1.1.7/setup.cfg
Running PIL-1.1.7/setup.py -q bdist_egg --dist-dir /var/folders/9q/bvqtzkbx1hg1934b36zgk0y40000gn/T/easy_install-wfZs_Y/PIL-1.1.7/egg-dist-tmp-DXWOmC
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
--- using frameworks at /System/Library/Frameworks
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1

Not sure if this helps, but when I run sudo port select --list gcc, I get the following:

Available versions for gcc:
    llvm-gcc42
    mp-gcc45
    none (active)
Community
  • 1
  • 1
sgarza62
  • 5,998
  • 8
  • 49
  • 69
  • 1
    @jdi Thanks for the link...but as I mentioned above, I have already installed the latest version of Xcode, and installed the Command Line Tools in the Xcode Preferences (which is the accepted solution in that link). Any ideas? – sgarza62 Dec 06 '12 at 23:20
  • Have you checked your /Developer location and/or other locations to make sure the problem is that you don't have it included in your `PATH`? Run this: `find /usr/local/bin /Developer/ -name "gcc" | grep "/bin" ` – jdi Dec 06 '12 at 23:24
  • @jdi When I run that, I get `find: /Developer/: No such file or directory` – sgarza62 Dec 06 '12 at 23:30
  • If that is all you see, it seems like gcc just isn't installed at all. What about `find /usr/ -name "gcc" | grep "/bin" ? Are you sure the command line tools were actually installed and not just downloaded? – jdi Dec 06 '12 at 23:36
  • You basically can't get `gcc-4.0` with OS X 10.8 and Xcode 4.5. But, except for a few badly-written packages (and PIL is not one), you will never need it, at least not for Apple's Python installations, or anything recent from python.org. So, unless you've somehow gotten `CC=gcc-4.0` into your shell environment, you've probably got a screwy Python installation from some other source. What does `which easy_install` say? – abarnert Dec 06 '12 at 23:41
  • @jdi: No, Apple stopped installing Xcode into `/Developer` quite some time ago; it goes in `/Applications/Xcode.app`. If you use the `xcrun` tool, or the stuff installed into `/usr/bin` by installing the Command Line Tools, you won't notice, but if you go looking for `/Developer` explicitly, of course you will. Also, the CLT are installed from Xcode's preferences (on the Downloads pane), which doesn't have a way to download without installing. (You can still find them on the website, but almost nobody knows that.) Also, `/usr/local/bin` will never find anything from Apple; you want `/usr/bin`. – abarnert Dec 06 '12 at 23:42
  • PS, as a general rule, if you have anything other than the built-in Apple Python installations, and you have a problem with your Python installation, you can't just say "Python version 2.7.3", you have to tell us whether it's the python.org installer, ActiveState, Homebrew, MacPorts, etc., or we can't possibly debug the problem other than by throwing a lot of questions at you. – abarnert Dec 06 '12 at 23:44
  • @jdi I get the following: `find: /usr//local/mysql-5.5.28-osx10.6-x86_64/data/performance_schema: Permission denied` `find: /usr//local/mysql-5.5.28-osx10.6-x86_64/data/riotry: Permission denied` `/usr//bin/gcc` `find: /usr//sbin/authserver: Permission denied` `/usr//share/TargetConfigs/bin/gcc` – sgarza62 Dec 06 '12 at 23:50
  • Well based on the information provided by @abarnert, maybe it didn't get symlinked properly from your `/Applications/Xcode.app` location. – jdi Dec 06 '12 at 23:52
  • @abarnert I get the following: `/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install` – sgarza62 Dec 06 '12 at 23:52
  • @jdi: `gcc-4.0` will not get symlinked anywhere, because it does not exist in modern Xcode, and nothing will get symlinked into `/usr/local/bin`, because Apple does not put anything there. All of your steps are just adding confusion. – abarnert Dec 06 '12 at 23:55

1 Answers1

0

This is just a guess, based on the fact that you must have MacPorts installed (or sudo port select --list gcc would just give you a port: command not found error), but I suspect you've installed a MacPorts Python 2.7.3, and you're trying to install PIL for that.

If you want to add packages to a MacPorts Python installation, you should always first check to see if there's a port for it, and, if so, use it:

port search pil

In this case, you'll find there is a py27-pil. Install that.

Meanwhile, when this doesn't apply, you should almost always use pip instead of easy_install (there are a few exceptions, notably readline), and you need to make sure your path is set up properly so you're running the one you think you are, or you may end up running scripts set up for MacPorts python with Apple python.

However, I also suspect you have an out-of-date MacPorts installation that you installed for an earlier version of OS X, and didn't follow the upgrade instructions when upgrading to Mountain Lion. If this is true, the only decent fix is to get a list of installed ports, sudo rm -rf /opt/local, run the latest MacPorts installer, then sudo port install all of the previously-installed ports.

On top of that, last time I used MacPorts Python (which is quite a long time ago, so it may not be current information), it didn't install things into /Library (IIRC, it set up /opt/local/Library as an extra library directory instead), which implies that you actually have at least three Python 2.7 installations: Apple's (in /System/Library and /usr), MacPorts (in /opt/local), and some other version (in /Library and probably /usr/local), and you're using the second one's easy_install when you meant to use the third.

If you don't know how to deal with this kind of multiple-copies-of-the-same-thing insanity, and you don't have a very, very good reason to invite it, the right answer is to not install these other Pythons (and uninstall any you already have). Do you actually need MacPorts python at all? Can you just use the built-in Python? If not, why not? And can you at least use the python.org Python?

If you don't want to fix any of the base problems, and you really want to install things into a MacPorts Python that expects you to have gcc-4.0 around, you might be able to install the macports gcc4.0 port, although you may have to trick things into believing that macports-gcc-4.0 is really gcc-4.0. (There might be a way to do that properly with MacPorts; if not, a symlink might work.) But this is probably a bad idea, and I wouldn't be surprised if you came back with "That seemed to work but then I got this other error 348 minutes into rebuilding stuff", and nobody would be able to help you.

abarnert
  • 354,177
  • 51
  • 601
  • 671
  • Thanks for your detailed answer. I do not have a good reason to use MacPorts python. What steps should I take to use the built-in Python or the python.org Python (what should I uninstall/configure)? I would highly appreciate an edit with the simplest step-by-step commands I should run to fix this problem. – sgarza62 Dec 07 '12 at 00:03
  • I believe `sudo port uninstall python27` will get it out of the way (while leaving it still built, in case you ever need it back). If you have a third Python, I can't be sure how to get rid of it without knowing which one—but if it's the python.org one, I'm pretty sure they have instructions somewhere on the website. After that, `which easy_install` should give you either `/usr/bin/easy_install` or a path inside `/System/Library` (note the `System` part), which means you're using Apple's python again. – abarnert Dec 07 '12 at 00:05
  • If I'm still getting this `/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install` when I run `which easy_install`, do I need to uninstall a third Python? – sgarza62 Dec 07 '12 at 00:19
  • I checked inside of `/usr/bin/` and `easy_install-2.7` is there. Is there anyway to have this `easy_install` used instead of the other one? – sgarza62 Dec 07 '12 at 00:33
  • @sgarza62: Yes, of course you can explicitly run `sudo /usr/bin/easy_install-2.7` instead of just running `sudo easy_install-2.7`. If you want to go that way, make sure you always run `/usr/bin/python2.7` instead of just `python2.7` or `python`, and so on, or you'll end up getting confused by the fact that you installed PIL and yet you can't import it because you're using a different Python 2.7 than you installed it for… but if you're consistent about this, it will work. Personally, I have a hard time being that consistent, and find it easier to keep my system in a state I can understand… – abarnert Dec 07 '12 at 01:01