解决pip升级失败问题

导入库是出现You are using pip version 19.0.3, however version 19.2.3 is available.问题
升级pip版本:win+r 输入cmd 回车

输入pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB)
    1% |▌                               | 20kB 6.3kB/s eta 0:03:43
 。。。
 。。。
 。。。
    一连串的红色字
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

不行,好烦,加个sudo

输入sudo pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB)
。。。
。。。
。。。
又是一连串的红色字
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

好吧,还是不行,怎么办呢 再加个–user

输入sudo pip install --upgrade pip --user
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/
Collecting pip
  Downloading https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 21kB/s
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.3

哎呀,终于成功了,不容易啊。。。。。

出现该情况是因为服务器连接超时

除了上面的方法外还可以输入下面两行:

python -m pip install --upgrade pip
python -m pip install -U pip

要是上面两行不可以,试试下面这个

easy_install --upgrade pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/
Collecting pip
  Downloading https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 21kB/s
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.3

OK,搞定,这样pip升级成功。

再次输入

pip --version

就会看到版本信息了

pip 19.2.3 from d:\python\lib\site-packages\pip (python 3.7)

指定位置安装

pip install 包名称 --target=指定位置

若有的文件夹已存在出现Warning

pip install 包名称 --upgrade --target=指定位置

你可能感兴趣的:(python学习笔记)