Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

pip command is mixed up in python2 and python3 #50607

Closed
mpathy opened this issue Apr 1, 2016 · 4 comments
Closed

pip command is mixed up in python2 and python3 #50607

mpathy opened this issue Apr 1, 2016 · 4 comments
Labels

Comments

@mpathy
Copy link

mpathy commented Apr 1, 2016

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.

@dunn dunn added the python label Apr 1, 2016
@MikeMcQuaid
Copy link
Member

What is your $PATH?

@tdsmith
Copy link
Contributor

tdsmith commented Apr 3, 2016

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.

@tdsmith tdsmith closed this as completed Apr 3, 2016
@mpathy
Copy link
Author

mpathy commented Apr 4, 2016

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?

@tdsmith
Copy link
Contributor

tdsmith commented Apr 4, 2016

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.

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants