pip 或 pip3 为 Python 3 安装软件包? [英] pip or pip3 to install packages for Python 3?

查看:51
本文介绍了pip 或 pip3 为 Python 3 安装软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台装有 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.

是不是说以前的版本不一样了,现在pippip3可以互换使用了?如果是这样,为了论证,我如何为 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 相同的可执行文件路径的软链接.你可以使用下面的命令来检查你的 pippip3 真实路径在哪里:

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

  • 将默认 pip 设置为某个版本.
  • 为不同的版本制作不同的链接.

python, python2, python3

如果您对它在不同情况下如何发生感兴趣,请在下面查看更多信息:

More information below if you're interested in how it happens in different cases:

这篇关于pip 或 pip3 为 Python 3 安装软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆