I have a Macbook with OS X El Captain. I think that Python 2.7
comes preinstalled on it. However, I installed Python 3.5
too. When I started using Python 3
, I read that if I want to install a package, I should type:
pip3 install some_package
Anyway, now when I use
pip install some_package
I get some_package
installed for Python 3
. I mean I can import it and use it without problems. Moreover, when I type just pip3
in Terminal
, I got this message about the usage:
Usage:
pip <command> [options]
which is the same message I get when I type just pip
.
Does it mean that in previos versions, things were different, and now pip
and pip3
can be used interchangeably? If so, and for the sake of argument, how can I install packages for Python 2
instead of Python 3
?
When you install
python3
,pip3
gets installed. And if you don't have another python installation(like python2.7) then a link is created which pointspip
topip3
.So
pip
is a link to topip3
if there is no other version of python installed(other than python3).pip
generally points to the first installation.If you had python 2.x and then installed python3, your pip will be pointing to pip3. you can verify that by typing
pip --version
which would be the same aspip3 --version
.On your system you have now pip, pip2 and pip3.
If you want you can change pip to point to pip2 instead of pip3.
If you installed Python 2.7, I think you could use
pip2
andpip2.7
to install packages specifically for Python 2, likeor
And you may use
pip3
orpip3.5
to install pacakges specifically for Python 3.This is a tricky subject. In the end, if you invoke
pip
it will invoke eitherpip2
orpip3
, depending on how you set your system up.I think
pip
,pip2
andpip3
are not soft links to the same executable file path. Note this commands and results in my linux terminal:As you see they are exist in different paths.
pip3 always operates on the Python3 environment only, as pip2 does with Python2. pip operates on whichever environment is appropriate to the context. For example if you are in a Python3 venv, pip will operate on the Python3 environment.
On my Windows instance - and I do not fully understand my environment - using pip3 to install the kaggle-cli package worked - whereas pip did not. I was working in a conda environment and the environments appear to be different.