4

I am fine having multiple distributions of Python on my system, given the advice found here.

However: I cannot get easy_install nor pip install to install to the distribution associated with /usr/bin/python on Mac. They will only install modules to the distribution associated with /Library/Python/2.6/.

This is a problem because both my default python calls and XCode compiles are associated with /usr/bin/python.

So, for example, when I try to pip install appscript, I get back a cheeky

Requirements already satisfied

But, then, when I open up python or XCode and try to import appscript, I get

ImportError: No module named appscript

How do I force pip to install to whatever distribution is associated with /usr/bin/python?

Community
  • 1
  • 1
Chris Redford
  • 16,982
  • 21
  • 89
  • 109
  • I have multiple pip scripts: pip (default python), pip-2.6, pip-2.7 etc... I'm on Gentoo though. – phant0m Jun 22 '11 at 13:07
  • 1
    This might help: http://stackoverflow.com/questions/5792060/easy-install-with-various-versions-of-python-installed-mac-osx – juanchopanza Jun 22 '11 at 13:23

2 Answers2

4

It turned out that easy_install (and pip) was not associated with Python 2.7 (the version used by my default python and XCode). Per vartec's instructions on an Answer that has now been deleted, I downloaded and installed easy_install for the correct version of python:

sh setuptools-0.6c11-py2.7.egg

(easy_install is part of setuptools)

After doing this, my default call to easy_install suddenly switched to installing packages for the distribution used by python and XCode.

Both python and XCode have access to appscript now, so whatever, I guess. Thanks for the help everyone, especially vartec.

Community
  • 1
  • 1
Chris Redford
  • 16,982
  • 21
  • 89
  • 109
  • Also note that you may need to reinstall pip in order for the setuptools changes to take effect, and for new pip-installed modules to appear in the python scope. – 4Z4T4R Feb 11 '13 at 21:37
  • Another way is to get a fresh https://bootstrap.pypa.io/get-pip.py and run it with your particular python binary, i.e. `/sw/bin/python2.7` and that will give you an alternate pip for that version of Python. – MarkHu Jul 19 '14 at 06:22
1

You should invoke the correct version of easy_install or pip. One way to do that is set the the version you want to work with on your path:

 export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH

This works for easy_install. For pip, you need to give the python environment to the pip command:

pip install -E /Library/Python/2.6/ appscript
rafalotufo
  • 3,862
  • 4
  • 25
  • 28
  • Sorry, I'm not following. You say I need to invoke the correct version of *pip* but then give me instructions for changing the path to *python*. Wouldn't that still be using the same version of pip? I'm a little wary about modifying my path without knowing exactly what you are talking about.. – Chris Redford Jun 22 '11 at 12:49
  • @Chris: both `easy_install` and `pip` are Python scripts, and their settings depend on Python interpreter used – vartec Jun 22 '11 at 12:56
  • I appreciate the offer of advice, rafalotufo, but this ultimately was not the solution that worked. – Chris Redford Jun 22 '11 at 13:17
  • 2
    The -E is not a valid argument flag for pip in my machine running OS 10.8.2 – 4Z4T4R Feb 11 '13 at 18:46