我针对Python 2
和3.
进行了开发
因此,我必须同时使用pip2
和pip3.
使用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
环境:
$ 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
答案 0 :(得分:26)
只需使用您已有的pip3
命令:
pip3 install --upgrade pip
已安装的项目始终称为pip
。 pip3
命令与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
。