我有一台装有 OS X El Captain 的 Macbook.我认为 Python 2.7
是预装的.但是,我也安装了 Python 3.5
.当我开始使用 Python 3
时,我读到如果我想安装一个包,我应该输入:
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
我为 Python 3
安装了 some_package
.我的意思是我可以导入它并毫无问题地使用它.此外,当我在 Terminal
中仅键入 pip3
时,我收到了有关用法的消息:
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]
这与我输入 pip
时得到的消息相同.
which is the same message I get when I type just pip
.
这是否意味着在以前的版本中,情况有所不同,现在 pip
和 pip3
可以互换使用?如果是这样,并且为了争论,我如何为 Python 2
而不是 Python 3
安装包?
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
?
您的 pip
是与 pip3
相同的可执行文件路径的软链接.您可以使用以下命令检查您的 pip
和 pip3
实际路径在哪里:
Your pip
is a soft link to the same executable file path with pip3
.
you can use the commands below to check where your pip
and pip3
real paths are:
$ ls -l `which pip`
$ ls -l `which pip3`
您也可以使用以下命令了解更多详情:
You may also use the commands below to know more details:
$ pip show pip
$ pip3 show pip
当我们安装不同版本的python时,我们可能会创建这样的软链接到
When we install different versions of python, we may create such soft links to
python
、python2
、python3
如果您对它在不同情况下的发生方式感兴趣,请在下面了解更多信息:
More information below if you're interested in how it happens in different cases:
这篇关于pip 或 pip3 为 Python 3 安装包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!