当默认点为pip2时,升级pip3的正确格式是什么?

时间:2016-08-24 17:20:10

标签: python python-3.x cygwin pip python-3.4

我针对Python 23.进行了开发 因此,我必须同时使用pip2pip3.

使用pip3 -时,我收到此升级请求(最后两行):

$ pip3 install arrow
Requirement already satisfied (use --upgrade to upgrade): arrow in c:\program files (x86)\python3.5.1\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in c:\program files (x86)\python3.5.1\lib\site-packages (from arrow)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in c:\program files (x86)\python3.5.1\lib\site-packages (from python-dateutil->arrow)
You are using pip version 7.1.2, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

我的默认pip适用于Python 2,,即:

$  python -m pip install --upgrade pip
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages

但是,以下显式命令均未成功升级Python 3 pip:

$  python -m pip3 install --upgrade pip3
/bin/python: No module named pip3

$  python -m pip install --upgrade pip3
Collecting pip3
  Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3

$  python -m pip install --upgrade pip3.4
Collecting pip3.4
  Could not find a version that satisfies the requirement pip3.4 (from versions: )
No matching distribution found for pip3.4

当pip3不是默认点时,升级pip3的正确命令是什么?

环境:

$ python3 -V
Python 3.4.3
$ uname -a
CYGWIN_NT-6.1-WOW 2.5.2(0.297/5/3) 2016-06-23 14:27 i686 Cygwin

2 个答案:

答案 0 :(得分:26)

只需使用您已有的pip3命令:

pip3 install --upgrade pip

已安装的项目始终称为pippip3命令与Python 3安装相关联,并且是pip的别名,但后者在Python 2安装程序中被pip命令遮蔽。

您也可以使用相关的Python二进制文件;如果它可执行为python3,则使用:

python3 -m pip install --upgrade pip

同样,项目被称为pip,安装在site-packages目录中的模块也是如此,所以坚持-m命令行选项的名称, install命令。

答案 1 :(得分:3)

当我搜索“如何更新pip3”时,这就出现了。我遇到了here所描述的问题:

问题

使用pip3升级可能会对Python 3版本提出pip

似乎不是这种情况(不再是)。

解决方案

在要升级之后更新要保留的那个。因此

pip3 install --upgrade pip
pip2 install --upgrade pip --force-reinstall

将确保pip指向pip2