pip or pip3 to install packages for Python 3?

2019-01-31 10:41发布

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?

7条回答
小情绪 Triste *
2楼-- · 2019-01-31 11:44

Your pip is soft link to the same executable file path with pip3. you can use below commands to check where your pip and pip3 real paths are:

$ ls -l `which pip`
$ ls -l `which pip3`

you may also use below commands to know more details:

$ pip show pip
$ pip3 show pip

When we installed different version of python, we may do such soft links to

  • set default pip to some version.
  • make different links for different versions.

it is same situation about python, python2, python3

Below for who interested in how it happens in different case:

查看更多
登录 后发表回答