Homebrew/legacy-homebrew

pip command is mixed up in python2 and python3

mpathy opened this issue · 4 comments

I installed python and python3 via brew, to have the newest packages and also pip preinstalled.

Said pip makes now problems because the command without the number shows to Python 3 when it is started, but the link shows to Python 2..

Whats the problem here?

(I did the general troubleshooting of course, too, and saw no errors..)

~$ python -V
Python 2.7.11
~$ python2 -V
Python 2.7.11
~$ python3 -V
Python 3.5.1
~$ pip -V
pip 8.1.1 from /usr/local/lib/python3.5/site-packages (python 3.5)
~$ pip2 -V
pip 8.1.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
~$ pip3 -V
pip 8.1.1 from /usr/local/lib/python3.5/site-packages (python 3.5)
~$ ll /usr/local/bin/pi*
lrwxr-xr-x  1 admin  admin    31B  1 Apr 11:40 /usr/local/bin/pip@ -> ../Cellar/python/2.7.11/bin/pip
lrwxr-xr-x  1 admin  admin    32B  1 Apr 11:40 /usr/local/bin/pip2@ -> ../Cellar/python/2.7.11/bin/pip2
lrwxr-xr-x  1 admin  admin    34B  1 Apr 11:40 /usr/local/bin/pip2.7@ -> ../Cellar/python/2.7.11/bin/pip2.7
lrwxr-xr-x  1 admin  admin    32B  1 Apr 10:24 /usr/local/bin/pip3@ -> ../Cellar/python3/3.5.1/bin/pip3
lrwxr-xr-x  1 admin  admin    34B  1 Apr 10:24 /usr/local/bin/pip3.5@ -> ../Cellar/python3/3.5.1/bin/pip3.5

Here the output of brew --config:

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: a1a71b8
Last commit: 3 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit sandybridge
OS X: 10.10.5-x86_64
Xcode: N/A
CLT: 7.2.0.0.1.1447826929
Clang: 7.0 build 700
X11: 2.7.8 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: N/A

If you need more information, I'll be happy to give it to you. Need a solution to continue working, and some tools depend on the "pip without number" command, so using the number is no option.

What is your $PATH?

If you're upgrading pip outside Homebrew, the pip command belongs to whichever Python installed pip last; this is unavoidable if python and python3 install scripts to the same prefix. See pypa/pip#2973. Run python -m pip -U --force-reinstall pip to force reinstalling pip on python2 which will rewrite the script again.

Alternatively, always prefer to invoke pip with e.g. python -m pip or python3 -m pip, which will always use the correct pip.

mikemcquaid:
/Users/admin/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/admin/.composer/vendor/bin
(I fix the bug with the composer but that is only cosmetic and php-relevant.)

I deinstalled all python and reinstalled it which worked also.

But how to update pip3?

pip 8.1.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)

Or should I invoke always pip instead of pip3 and then specify python3 to use from the python2 pip?

python3 -m pip install -U --force-reinstall pip
python -m pip install -U --force-reinstall pip

will leave you with a pip pointing to python2, a pip2 pointing to python2, and a pip3 pointing to python3.