Pregunta

I'm a front-end developer with zero server-side experience. I'm trying to learn a little python for an app I'm building, and I literally cannot find anywhere that makes it easy to install easy_install. Everything I read is full of lingo I don't get, like using homebrew or PATHs. And pypi.python.org is TERRIBLY written and designed. So far it's only sent me in circles.

I'm looking for a simple set of instructions in the following format:

  1. Go to x website and click x link

  2. Type x into the terminal and run

  3. Type x to be sure it's installed properly

Please for the benefit of myself and the whole internet, can someone provide this? I'm definitely up for learning how to do some things the hard way, but Python isn't something I need to know very thoroughly right now, and I imagine that's the case for others just looking to get their feet wet.

Assume I have Python installed, but not that I know anything else about using it.

(If there really is a resource out there like this that exists, let me know... I just haven't seen anything like it yet and I've been googling around for about an hour.)

Thank you!

¿Fue útil?

Solución

easy_install is part of setuptools. For a while, distribute was a separate fork of setuptools that included its own easy_install, and you had to put a bit of thought into which one you wanted, but that's no longer an issue; the two have merged back into one project. So, the question is, how do you get setuptools?


  • If you're using Apple's pre-installed versions of Python, you already have setuptools, with a working easy_install, for all versions. You can also use easy_install-2.5, etc., for the earlier versions of Python that Apple also pre-installs. So there's nothing to do.
  • If you're using a Homebrew Python, it automatically installs setuptools by default, so again, nothing to do.
  • If you're using a third-party package manager that doesn't automatically install setuptools (as at least was true for MacPorts last time I checked), it probably has its own package for python32-setuptools or python32-easy-install or something like that.
  • Most of the "extra-batteries" distributions (ActiveState, Enthought, etc.) of Python similarly include setuptools, so again, nothing to do.

If you're using a Python.org binary, a custom-built Python with default configuration, etc., the standard setuptools instructions for "Unix-based Systems including Mac OS X" work fine.

If you installed Python somewhere you don't have write access, you will need to sudo the installation step, as in the second variant.

So:

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python

And that's all there is to it.


All that being said, you almost never want to use easy_install, except to install two things:

  • readline, to replace the fake libedit-based support with real libreadline-based support. (And any other packages that don't work with pip, but this is the only really popular one.)
  • pip, so you never need to use easy_install again.

Most of the cases above that include setuptools also include pip; the one exception is Apple pre-installed Python, where sudo easy_install pip is the simplest way to get pip.

For the cases that don't come with either, the standard documentation for installing pip also works:

  • Install or upgrade setuptools (as above) if you have a version older than 0.7.
  • Download get-pip.py.
  • python get-pip.py

Again, sudo if you need to, and replace the python with python3.3 or python2.6 or /opt/local/mypython/bin/python or whatever to install for any non-default versions.


Finally, for upgrading, once you have any version of pip, and setuptools 0.7 or later, it's as easy as you could imagine:

pip install --upgrade setuptools pip

Again, sudo if necessary, and pip-3.3 or whatever if necessary.


Note that to make easy_install or pip actually useful, you may need a compiler toolchain. The easy way to do this is to install Xcode from the Mac App Store (free as of late 2013), launch Xcode, open Preferences, go to Downloads, and install the "Command Line Tools". This is sufficient for almost everything you'd ever want to do.

The one major exception is SciPy and related packages, for which you will also need a Fortran compiler. See this blog post for Python 2.x and this one for 3.x for details. If all of that looks scary to you, you may be happier using Enthought or one of the other pre-packaged scientific distributions.


One last thing: If you installed a non-Apple Python, and then upgraded your OS X (or Homebrew or MacPorts or Enthought or …) to a newer major version (e.g., from OS X 10.8 to 10.9), you may need some extra steps. For every case but OS X itself, they should be documented on the home page for whichever package manager or Python distribution you're using. For an OS X upgrade, reinstalling your third-party Python is usually the simplest solution if you run into a problem (after first verifying that you actually need a third-party Python in the first place), even if it means you have to reinstall your site packages.

Otros consejos

The short correct answer is don't use EasyInstall.

Use pip!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top