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

查看:277
本文介绍了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

无论如何,现在我使用

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.

这是否意味着在previos版本中情况有所不同,并且现在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

  • 将默认点设置为某些版本.
  • 为不同版本创建不同的链接.

pythonpython2python3

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

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

  • MacOS/Homebrew
  • Fedora/CentOS
  • Debian/Ubuntu

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

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