0

This question shows how to use pip for different python versions. However, I have the same version of python installed in two different paths. Let's not ask why, if I remove one, things break.

$ /usr/local/bin/python -c "import sys; print sys.version"
2.7.10 (default, Jun 10 2015, 19:42:47) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]
$ /usr/bin/python -c "import sys; print sys.version"
2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]

pip seems to install packages to /usr/local/bin/python.

How do I install a package to /usr/bin/python?

I'm on OS X, Yosemite (10.10).

Community
  • 1
  • 1
dfrankow
  • 20,191
  • 41
  • 152
  • 214

2 Answers2

1

For two python installations you can have two pips.

Install a pip for the other python:

sudo /usr/bin/python -m easy_install pip

Execute pip as a module:

/usr/bin/python -m pip install --user your_package

Recommend to symlink them to separate names.

wim
  • 338,267
  • 99
  • 616
  • 750
0

you could :

  1. update your PATH variable to give priority to /usr/bin/python over /usr/local/bin/python

  2. call pip by its full path:

    /usr/bin/pip install package

[EDIT] pip seems not to be present on /usr/bin on Yosemite, so you should use easy_install instead

/usr/bin/easy_install package
Pierre Michard
  • 1,341
  • 1
  • 12
  • 16
  • Thanks! pip has a shebang (#!) of the wrong python. Then, when I try executing it directly (/usr/bin/python `which pip` install package), the right python complains it doesn't know pip exists. I'm afraid to easy-install for /usr/bin/python for fear pip will freak out. – dfrankow Dec 23 '15 at 22:46
  • If you have two installations of python, you can/should have two installations of pip. Trying to use the same version of pip for multiple python versions will be a world of pain .. – wim Dec 23 '15 at 22:48
  • This might have worked, but I got the other one to work, so off I go. Thanks. – dfrankow Dec 23 '15 at 22:51