pipエラー:ImportError:cannot import name'main'from'pip.internal' (unknown location)

1574 ワード

テキストリンク: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