25

I recently installed python 2.7.2 on my Mac running OSX 10.6.8. Previously, I had version 2.6. I set my path in .bash_profile as follows:

export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH

so that when I run python it will refer to my new installation. It does.

I would also like to use pip with my new installation, but the problem is that I already have the current version of pip installed at

/usr/local/bin/pip.

I tried to re-install pip with:

easy_install pip

But, of course this does not put pip in the desired new directory

/usr/local/share/python/pip

but simply refers to the existing version in /usr/local/bin/pip.

Can someone tell me how to fix this?

I would like to then use pip to install NumPy and SciPy in the correct directory (I was having trouble getting the SciPy installation to work with my old version of python, hence the new install).

If you'd like, you can visit the website where I found instructions for installing python 2.7, creating/updating my .bash_profile, installing pip, and NumPy and SciPy. Might provide some insight, or I'm happy to give more details if needed. Thanks! http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/#python

python4ecology
  • 275
  • 1
  • 3
  • 7

7 Answers7

18

Install distribute as per the instructions at http://pypi.python.org/pypi/distribute . Make sure you specify the full path to the python executable (/usr/local/share/python/python or smth in your case).

$ curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
$ /usr/local/share/python/python distribute_setup.py

Then you should have /usr/local/share/python/easy_install.

After that, run:

$ /usr/local/share/python/easy_install pip

Then you should have /usr/local/share/python/pip.

Depending on the ordering of things in your PATH, either your old, or the newly installed pip is executed when you execute the pip command, so you either might have to adapt your PATH, or specify the full path to /usr/local/share/python/pip when installing eggs.

(shameless plug: In any case, you might consider using virtualenv for installing packages into a "project" specific isolated environment, as opposed to installing them globally.)

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
  • $ /usr/local/bin/python/ distribute_setup.py Gives: '/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'distribute_setup.py': [Errno 2] No such file or directory' $ python distribute_setup.py Installs to '/Library/Frameworks/Python.framework/Versions/2.7/bin' But when I then try to install pip, it finds the pip in my old version (2.6) instead (says: Processing pip-1.0-py2.6.egg pip 1.0 is already the active version in easy-install.pth) – python4ecology Mar 21 '12 at 15:36
  • I also tried: $ /usr/local/bin/python/easy_install pip Because 'which python' gives /usr/local/bin/python But, it says: Not a directory Any more ideas? Thanks for your help! – python4ecology Mar 21 '12 at 15:38
  • Your $PATH may have wrong hardcoded python versions. At least I had in my mac. – Hugo Lopes Tavares Mar 27 '12 at 15:49
  • 4
    Maybe obvious to you. If I already knew everything, I wouldn't have to ask the question. Thanks anyway, Erik. – python4ecology Oct 03 '13 at 16:56
  • @python4ecology: no probs; didn't mean to offend! – Erik Kaplun Oct 03 '13 at 19:25
  • 1
    The legacy link to distribute doesn't really have any useful information anymore. For anyone looking to download `distribute_setup.py`, try this - https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py – Blake Sep 14 '15 at 23:35
  • @ErikAllik Could you please update your answer to reflect the correct url since as of at lease 2015 your curl command does not work. – Dwight Spencer Sep 21 '15 at 17:11
10

I needed to uninstall brew's python.

Then, I was left with python v2.7.6

Next to install, pip I ran

sudo easy_install pip

installed fine and working

JGallardo
  • 11,074
  • 10
  • 82
  • 96
cooldude8
  • 111
  • 1
  • 2
6

I had a similar issue, try this:

$ python -m pip install --upgrade --force-reinstall pip

This will force reinstall pip with whatever version of python you use including installing the binary.

Michael Lenzen
  • 822
  • 8
  • 7
3

A few days ago I had a friend who was starting Python Programming and needed help with the same issue: installing pip. There are debates over which one to choose between easy_install and pip and it seems everybody is heading the pip direction. Either way, installing either of them can be frustrating.

You can use this simple tutorial : installing pip package manager the easy way

Here are what you should keep in mind as you follow the above guide:

  • If you already have an older version installed, uninstall it or totally remove the python installation
  • Once that is cleared, download an install Python.
  • After that, download ez_setup.py file and save it to your desktop - easily accessible from the command line
  • Now run it from the command line and it will install easy_install for you after which,
  • You can use it to install pip.

Once again, you can do this or use the above link to find a simple step-by-step guide on how to get it installed on your computer. Good luck.

Eenvincible
  • 5,641
  • 2
  • 27
  • 46
2

Just so that people knew, ATM we can install PIP by downloading get-pip.py from the page with docs and run it like this:

c:\python27\python.exe get-pip.py

BTW, Python 3.4 comes with PIP pre-installed.

Pugsley
  • 1,146
  • 14
  • 14
1

One of the command line options lets you choose where to install to.

--install-dir (-d) install package to DIR

So something like - # easy_install pip -d /usr/local/share/python

(Please correct me if I'm wrong.)

Brigand
  • 84,529
  • 20
  • 165
  • 173
  • 1
    When I do this, it says: 'Searching for pip Best match: pip 1.0 Processing pip-1.0-py2.6.egg pip 1.0 is already the active version in easy-install.pth Installing pip script to /usr/local/bin Installing pip-2.6 script to /usr/local/bin Using /Library/Python/2.6/site-packages/pip-1.0-py2.6.egg Processing dependencies for pip Finished processing dependencies for pip Searching for -d Reading http://pypi.python.org/simple/-d/ Couldn't find index page for '-d' (maybe misspelled?)' – python4ecology Mar 21 '12 at 15:25
  • Continued: 'Scanning index of all packages (this may take a while) Reading http://pypi.python.org/simple/ No local packages or download links found for -d error: 'Could not find suitable distribution for Requirement.parse('-d')' Any thoughts on that? – python4ecology Mar 21 '12 at 15:27
  • Odd... I'm not that experienced with `easy_install`, and I was just going from the help message (`easy_install -h`). I hope someone else can be more helpful. – Brigand Mar 21 '12 at 15:41
1

Just wanted to say that I found a way to get around my problem. I don't know that I can explain it perfectly, since I am not very good at understanding what I am doing with this stuff just yet! But, the problem seems to have been with my PATH. I removed the PATH that I posted in my original question, and then used easy_install pip. It went straight to python 2.7.2 (my new version) with no problem. I then successfully used pip to install NumPy and SciPy in the correct location, and they both work. Thanks to ErikAllik and FakeRainBrigand for taking the time to look into it!

python4ecology
  • 275
  • 1
  • 3
  • 7