当前位置:   article > 正文

使用pip安装模块时提示: No module named pip 或 No module named ‘pip._internal‘ 解决方法_python get-pip.py --force-reinstall

python get-pip.py --force-reinstall

No module named pip 解决方法:

python -m ensurepip

C:\WINDOWS\system32>python -m ensurepip
Looking in links: C:\Users\Dell\AppData\Local\Temp\tmp3zn14kmm
Requirement already satisfied: setuptools in d:\program files(x86)\python37\lib\site-packages (39.0.1)
Collecting pip
Installing collected packages: pip
Successfully installed pip-10.0.1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

经过上述操作后,会出现以下错误:

C:\WINDOWS\system32>pip install --upgrade pip
Traceback (most recent call last):
  File "d:\program files(x86)\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\program files(x86)\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Program Files(x86)\Python37\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip._internal.cli'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

No module named ‘pip._internal.cli’ 解决方法:

  1. 强制重新安装pip3
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python get-pip.py --force-reinstall
C:\WINDOWS\system32>curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1840k  100 1840k    0     0   920k      0  0:00:02  0:00:02 --:--:--  736k
  • 1
  • 2
  • 3
  • 4
C:\WINDOWS\system32>python get-pip.py --force-reinstall
Collecting pip
  Using cached pip-20.2.2-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-20.2.2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  1. 验证安装
    pip show pip
C:\WINDOWS\system32>pip show pip
Name: pip
Version: 20.2.2
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: d:\program files(x86)\python37\lib\site-packages
Requires:
Required-by:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

参考资料:
【1】使用pip安装模块时提示: No module named pip
【2】pip升级时报错— No module named ‘pip._internal’

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/1000198
推荐阅读
相关标签
  

闽ICP备14008679号