本文最后更新于:2024年1月14日 晚上

windws 10 下升级 pip ,升级时下载安装包,卸载原有pip成功,在安装新pip包时因种种原因安装失败会导致pip被卸载,本文记录修复方法 。

常见原因

  • Windows 中anaconda文件夹没有为users用户开放全部控制权限
  • 在更新pip时命令为(这是错误的命令):
1
pip install -U pip

此时pip从服务器下载了最新的pip安装包,卸载了原来的pip,但是没有权限安装新的pip

导致使用此命令更新pip后无pip可用

正确命令shell

  • 在选项中加入 --user
1
pip install --upgrade pip --user

修复命令

  • 如果不慎中招,可以使用如下命令恢复
1
2
python -m ensurepip
python -m pip install --upgrade pip

实际效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$ pip list
Traceback (most recent call last):
File "e:\program_files\annoconda\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "e:\program_files\annoconda\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:\Program_Files\Annoconda\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

$ python -m ensurepip
Looking in links: C:\Users\Admin\AppData\Local\Temp\tmp1ggp6o2t
Requirement already satisfied: setuptools in e:\program_files\annoconda\lib\site-packages (45.1.0)
Collecting pip
jupyterlab 2.1.0 has requirement jupyterlab_server>=1.1.0, but you'll have jupyterlab-server 1.0.0 which is incompatible.
jupyterlab-server 1.0.0 has requirement jsonschema>=3.0.1, but you'll have jsonschema 2.6.0 which is incompatible.
imgviz 1.1.0 has requirement Pillow>=5.3.0, but you'll have pillow 5.2.0 which is incompatible.
Installing collected packages: pip
Successfully installed pip-10.0.1

$ python -m pip install --upgrade pip
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting pip
Using cached https://mirrors.aliyun.com/pypi/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl
jupyterlab 2.1.0 has requirement jupyterlab_server>=1.1.0, but you'll have jupyterlab-server 1.0.0 which is incompatible.
jupyterlab-server 1.0.0 has requirement jsonschema>=3.0.1, but you'll have jsonschema 2.6.0 which is incompatible.
imgviz 1.1.0 has requirement Pillow>=5.3.0, but you'll have pillow 5.2.0 which is incompatible.
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-20.1.1
You are using pip version 20.1.1, however version 20.2b1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.


文章链接:
https://www.zywvvd.com/notes/environment/pip/pip-upgrade-error/pip-upgrade-error/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

Windows pip upgrade 报错 No module named 'pip'
https://www.zywvvd.com/notes/environment/pip/pip-upgrade-error/pip-upgrade-error/
作者
Yiwei Zhang
发布于
2020年5月30日
许可协议