pip报错:ImportError: cannot import name 'main' from 'pip._internal' (unknown location)

原文链接: https://blog.csdn.net/wwangfabei1989/article/details/80107147

今天下载python包时出现了一个错误:

C:\Users\admin>pip3 install xlwt
Traceback (most recent call last):
  File "d:\python\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\python\Scripts\pip3.exe\__main__.py", line 5, in 
ImportError: cannot import name 'main' from 'pip._internal' (unknown location)

可以首先执行 python -m ensurepip 然后执行 python -m pip install --upgrade pip 即可更新完毕。

C:\Users\admin>python -m ensurepip
Looking in links: C:\Users\Public\Documents\Wondershare\CreatorTemp\tmpexe8fan4
Requirement already satisfied: setuptools in d:\python\lib\site-packages (40.6.2)
Collecting pip
Installing collected packages: pip
Successfully installed pip-18.1

C:\Users\admin>python -m pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.2.3

C:\Users\admin>pip3 install xlwt
Requirement already satisfied: xlwt in d:\python\lib\site-packages (1.3.0)

成功了

参考:https://blog.csdn.net/wwangfabei1989/article/details/80107147

你可能感兴趣的:(python)