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:
我有OS X El Captain的Macbook。我认为Python 2.7已预装在它上面。但是,我也安装了Python 3.5。当我开始使用Python 3时,我读到如果我想安装一个包,我应该输入:
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:
我为Python 3安装了some_package。我的意思是我可以导入它并毫无问题地使用它。而且,当我在终端中输入pip3时,我收到了有关用法的消息:
Usage:
pip <command> [options]
which is the same message I get when I type just pip
.
当我输入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
?
这是否意味着在previos版本中,事情是不同的,现在pip和pip3可以互换使用?如果是这样,并且为了论证,我如何安装Python 2而不是Python 3的软件包?
7 个解决方案
#1
24
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:
您的pip是与pip3相同的可执行文件路径的软链接。您可以使用以下命令检查您的pip和pip3实际路径的位置:
$ 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
当我们安装不同版本的python时,我们可能会进行这样的软链接
- set default pip to some version.
- make different links for different versions.
将默认点设置为某个版本。
为不同版本制作不同的链接。
it is same situation about python
, python2
, python3
有关python,python2,python3的相同情况
#2
9
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 as pip3 --version
.
如果你有python 2.x然后安装python3,你的pip将指向pip3。您可以通过键入pip --version来验证这与pip3 --version相同。
On your system you have now pip, pip2 and pip3.
在你的系统上你现在有pip,pip2和pip3。
If you want you can change pip to point to pip2 instead of pip3.
如果你想要你可以改变pip指向pip2而不是pip3。
#3
6
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 points pip
to pip3
.
安装python3时,会安装pip3。如果你没有其他python安装(如python2.7),那么会创建一个指向pip3的链接。
So pip
is a link to to pip3
if there is no other version of python installed(other than python3). pip
generally points to the first installation.
所以如果没有安装其他版本的python(除python3之外),pip是指向pip3的链接。 pip一般指向第一次安装。
#4
5
This is a tricky subject. In the end, if you invoke pip
it will invoke either pip2
or pip3
, depending on how you set your system up.
这是一个棘手的主题。最后,如果您调用pip,它将调用pip2或pip3,具体取决于您设置系统的方式。
#5
2
If you installed Python 2.7, I think you could use pip2
and pip2.7
to install packages specifically for Python 2, like
如果您安装了Python 2.7,我认为您可以使用pip2和pip2.7专门为Python 2安装软件包,例如
pip2 install some_pacakge
or
pip2.7 install some_package
And you may use pip3
or pip3.5
to install pacakges specifically for Python 3.
您可以使用pip3或pip3.5专门为Python 3安装pacakges。
#6
1
I think pip
, pip2
and pip3
are not soft links to the same executable file path. Note this commands and results in my linux terminal:
我认为pip,pip2和pip3不是指向同一可执行文件路径的软链接。在我的linux终端中注意这个命令和结果:
mrz@mrz-pc ~ $ ls -l `which pip`
-rwxr-xr-x 1 root root 292 Nov 10 2016 /usr/bin/pip
mrz@mrz-pc ~ $ ls -l `which pip2`
-rwxr-xr-x 1 root root 283 Nov 10 2016 /usr/bin/pip2
mrz@mrz-pc ~ $ ls -l `which pip3`
-rwxr-xr-x 1 root root 293 Nov 10 2016 /usr/bin/pip3
mrz@mrz-pc ~ $ pip -V
pip 9.0.1 from /home/mrz/.local/lib/python2.7/site-packages (python 2.7)
mrz@mrz-pc ~ $ pip2 -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
mrz@mrz-pc ~ $ pip3 -V
pip 9.0.1 from /home/mrz/.local/lib/python3.5/site-packages (python 3.5)
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.
pip3总是只在Python3环境中运行,就像pip2对Python2一样。 pip适用于适合上下文的环境。例如,如果你在Python3 venv中,pip将在Python3环境中运行。
#7
0
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.
在我的Windows实例上 - 我并不完全了解我的环境 - 使用pip3安装kaggle-cli包工作 - 而pip没有。我在conda环境中工作,环境似乎不同。
(fastai) C:\Users\redact\Downloads\fast.ai\deeplearning1\nbs>pip --version
(fastai)C:\ Users \ redact \ Downloads \ fast.ai \ deeplearning1 \ nbs> pip --version
pip 9.0.1 from C:\ProgramData\Anaconda3\envs\fastai\lib\site-packages (python 3.6)
来自C:\ ProgramData \ Anaconda3 \ envs \ fastai \ lib \ site-packages(python 3.6)的pip 9.0.1
(fastai) C:\Users\redact\Downloads\fast.ai\deeplearning1\nbs>pip3 --version
(fastai)C:\ Users \ redact \ Downloads \ fast.ai \ deeplearning1 \ nbs> pip3 --version
pip 9.0.1 from c:\users\redact\appdata\local\programs\python\python36\lib\site-packages (python 3.6)
pip 9.0.1来自c:\ users \ redact \ appdata \ local \ programs \ python \ python36 \ lib \ site-packages(python 3.6)
#1
24
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:
您的pip是与pip3相同的可执行文件路径的软链接。您可以使用以下命令检查您的pip和pip3实际路径的位置:
$ 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
当我们安装不同版本的python时,我们可能会进行这样的软链接
- set default pip to some version.
- make different links for different versions.
将默认点设置为某个版本。
为不同版本制作不同的链接。
it is same situation about python
, python2
, python3
有关python,python2,python3的相同情况
#2
9
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 as pip3 --version
.
如果你有python 2.x然后安装python3,你的pip将指向pip3。您可以通过键入pip --version来验证这与pip3 --version相同。
On your system you have now pip, pip2 and pip3.
在你的系统上你现在有pip,pip2和pip3。
If you want you can change pip to point to pip2 instead of pip3.
如果你想要你可以改变pip指向pip2而不是pip3。
#3
6
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 points pip
to pip3
.
安装python3时,会安装pip3。如果你没有其他python安装(如python2.7),那么会创建一个指向pip3的链接。
So pip
is a link to to pip3
if there is no other version of python installed(other than python3). pip
generally points to the first installation.
所以如果没有安装其他版本的python(除python3之外),pip是指向pip3的链接。 pip一般指向第一次安装。
#4
5
This is a tricky subject. In the end, if you invoke pip
it will invoke either pip2
or pip3
, depending on how you set your system up.
这是一个棘手的主题。最后,如果您调用pip,它将调用pip2或pip3,具体取决于您设置系统的方式。
#5
2
If you installed Python 2.7, I think you could use pip2
and pip2.7
to install packages specifically for Python 2, like
如果您安装了Python 2.7,我认为您可以使用pip2和pip2.7专门为Python 2安装软件包,例如
pip2 install some_pacakge
or
pip2.7 install some_package
And you may use pip3
or pip3.5
to install pacakges specifically for Python 3.
您可以使用pip3或pip3.5专门为Python 3安装pacakges。
#6
1
I think pip
, pip2
and pip3
are not soft links to the same executable file path. Note this commands and results in my linux terminal:
我认为pip,pip2和pip3不是指向同一可执行文件路径的软链接。在我的linux终端中注意这个命令和结果:
mrz@mrz-pc ~ $ ls -l `which pip`
-rwxr-xr-x 1 root root 292 Nov 10 2016 /usr/bin/pip
mrz@mrz-pc ~ $ ls -l `which pip2`
-rwxr-xr-x 1 root root 283 Nov 10 2016 /usr/bin/pip2
mrz@mrz-pc ~ $ ls -l `which pip3`
-rwxr-xr-x 1 root root 293 Nov 10 2016 /usr/bin/pip3
mrz@mrz-pc ~ $ pip -V
pip 9.0.1 from /home/mrz/.local/lib/python2.7/site-packages (python 2.7)
mrz@mrz-pc ~ $ pip2 -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
mrz@mrz-pc ~ $ pip3 -V
pip 9.0.1 from /home/mrz/.local/lib/python3.5/site-packages (python 3.5)
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.
pip3总是只在Python3环境中运行,就像pip2对Python2一样。 pip适用于适合上下文的环境。例如,如果你在Python3 venv中,pip将在Python3环境中运行。
#7
0
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.
在我的Windows实例上 - 我并不完全了解我的环境 - 使用pip3安装kaggle-cli包工作 - 而pip没有。我在conda环境中工作,环境似乎不同。
(fastai) C:\Users\redact\Downloads\fast.ai\deeplearning1\nbs>pip --version
(fastai)C:\ Users \ redact \ Downloads \ fast.ai \ deeplearning1 \ nbs> pip --version
pip 9.0.1 from C:\ProgramData\Anaconda3\envs\fastai\lib\site-packages (python 3.6)
来自C:\ ProgramData \ Anaconda3 \ envs \ fastai \ lib \ site-packages(python 3.6)的pip 9.0.1
(fastai) C:\Users\redact\Downloads\fast.ai\deeplearning1\nbs>pip3 --version
(fastai)C:\ Users \ redact \ Downloads \ fast.ai \ deeplearning1 \ nbs> pip3 --version
pip 9.0.1 from c:\users\redact\appdata\local\programs\python\python36\lib\site-packages (python 3.6)
pip 9.0.1来自c:\ users \ redact \ appdata \ local \ programs \ python \ python36 \ lib \ site-packages(python 3.6)