Windows pip upgrade 报错 No module named 'pip'

2022-08-05 10:41:16 浏览数 (1)

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

常见原因

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

此时pip从服务器下载了最新的pip安装包,卸载了原来的pip,但是没有权限安装新的pip 导致使用此命令更新pip后无pip可用

正确命令shell

  • 在选项中加入 --user
代码语言:javascript复制
pip install --upgrade pip --user

修复命令

  • 如果不慎中招,可以使用如下命令恢复
代码语言:javascript复制
python -m ensurepip
python -m pip install --upgrade pip

实际效果

代码语言:javascript复制
$ pip list
Traceback (most recent call last):
  File "e:program_filesannocondalibrunpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "e:program_filesannocondalibrunpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "E:Program_FilesAnnocondaScriptspip.exe__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

$ python -m ensurepip
Looking in links: C:UsersAdminAppDataLocalTemptmp1ggp6o2t
Requirement already satisfied: setuptools in e:program_filesannocondalibsite-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.

0 人点赞