pip损坏导致无法安装依赖

如题,pip损坏

可能会看到

Traceback (most recent call last):
  File "/usr/bin/pip3", line 11, in <module>
    load_entry_point('pip==20.1.1', 'console_scripts', 'pip3')()
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand, with_cleanup
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 16, in <module>
    from pip._internal.index.package_finder import PackageFinder
  File "/usr/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 21, in <module>
    from pip._internal.index.collector import parse_links
  File "/usr/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 14, in <module>
    from pip._vendor import html5lib, requests
ImportError: cannot import name 'requests' from 'pip._vendor' (/usr/lib/python3.8/site-packages/pip/_vendor/__init__.py)

这样的报错。

解决方案

重新安装pip

1.首先执行

python3 -m ensurepip --default-pip

2.然后下载 get-pip.py

wget  https://bootstrap.pypa.io/get-pip.py

3.运行脚本完成安装

python get-pip.py

 

版权声明:
作者:魂焱
链接:https://www.hunyan6.cn/674/
来源:魂焱小站
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>
文章目录
关闭
目 录