0

Getting this error when installing node via Homebrew:

brew install node
==> Downloading http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.10.24.tar.gz
==> Patching
patching file tools/gyp/pylib/gyp/xcode_emulation.py
==> ./configure --prefix=/usr/local/Cellar/node/0.10.24
env: python: No such file or directory

What's going on here?

python --version returns Python 2.7.6 and which python points to /usr/local/bin/python.

wikichen
  • 2,253
  • 3
  • 18
  • 28
  • Many brew recipes that require Python for building (but don't depend on it) go out of their way to avoid using any Homebrew-installed Python and instead use your Apple-provided Python (the one in `/usr/bin/python`). Have you somehow broken that? If you start a new shell without `/usr/local/bin` on your `PATH`, or just temporarily `brew unlink python` (you can always `brew link python` to turn it back on), does `which python` point at `/usr/bin/python`, or fail? – abarnert Jan 10 '14 at 23:23
  • … however, looking at the recipe, this one just uses `Python27Dependency`, which I'm pretty sure means "use the brew Python 2.7 if present, Apple 2.7 otherwise", and therefore shouldn't monkey with the environment to hide the brew one. So, still worth checking that your Apple Python isn't broken, but probably not the problem. – abarnert Jan 10 '14 at 23:28
  • You're a lifesaver, my `/usr/bin/python` didn't even exist, managed to find [this thread](http://stackoverflow.com/questions/15236832/how-do-i-reinstall-a-directory-in-usr-bin-python) about fixing broken symlinks, linked the 2.7 executable and now everything's working. If you add your answer below I'll accept it. :) – wikichen Jan 10 '14 at 23:51
  • OK, that solution isn't very good. It _might_ be good enough… but you're better off fixing this properly, if you can. Unfortunately, I'm not 100% sure how to fix it properly. In older versions, you could just boot the installer DVD and tell it to repair (which might revert you back to 10.X.0 and force you to re-update to 10.X.Y, but wouldn't break anything in your home directory, /usr/local, /Library, etc.), but in 10.8 and 10.9… no idea how to get to that feature. If you need help with that, try [SuperUser](http://superuser.com). – abarnert Jan 11 '14 at 00:10
  • Yikes, that makes me kind of nervous -- thanks for the tip! – wikichen Jan 25 '14 at 00:32

1 Answers1

1

It looks like the root problem was that your Apple-supplied Python was somehow broken—it was there enough for Homebrew to find it and set up the environment to use it, but not there enough to actually run—as in /usr/bin/python doesn't exist, and therefore /usr/bin/env python finds nothing when run in an environment without the Homebrew stuff added.

You really ought to figure out how you did that, and then fix it. That might require updating or repairing OS X. (I don't actually know how to do that anymore in 10.8 or 10.9, but that's a great question for SuperUser.) All kinds of other things can break if your Apple Python is broken, including everything from OS services to random bits deep inside some Homebrew port.

Creating a symlink from /usr/bin/python2.7 to /usr/bin/python will sort of work, but it's really not right. /usr/bin/python is a special stub executable that can be used (depending on global settings and environment-variable flags) to run any of the Python versions in /System/Library/Frameworks/Python.framework (normally that's 2.7, 2.6, 2.5, and a partial 2.3), while /usr/bin/python2.7 is a stub executable that just runs the 2.7 version. You might get away with it, but I wouldn't unless you really have no choice.

abarnert
  • 354,177
  • 51
  • 601
  • 671