pip报错

windows在使用python2的pip安装其他库的时候报错

Traceback (most recent call last):
  File "c:\Python27_x86\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\Python27_x86\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "c:\Python27_x86\lib\site-packages\pip\__main__.py", line 16, in <module>
    from pip._internal import main as _main  # isort:skip # noqa
  File "c:\Python27_x86\lib\site-packages\pip\_internal\__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "c:\Python27_x86\lib\site-packages\pip\_internal\cli\autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "c:\Python27_x86\lib\site-packages\pip\_internal\cli\main_parser.py", line 11, in <module>
    from pip._internal.commands import (
  File "c:\Python27_x86\lib\site-packages\pip\_internal\commands\__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "c:\Python27_x86\lib\site-packages\pip\_internal\commands\completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "c:\Python27_x86\lib\site-packages\pip\_internal\cli\base_command.py", line 26, in <module>
    from pip._internal.index import PackageFinder
ImportError: cannot import name PackageFinder

此时命令行单独运行pip也是报这个错误,用pip install --upgrade pip也无法更新

如何处理?

下载python2所支持的最新的tar包并离线安装

pip 20.3.2 will remove Python 2 support,pip 20.3.2以后不支持python2

https://pypi.org/project/pip/20.3.1/#files

https://files.pythonhosted.org/packages/cb/5f/ae1eb8bda1cde4952bd12e468ab8a254c345a0189402bf1421457577f4f3/pip-20.3.1.tar.gz

对于python2来说, 20.3.1就是最新的版本

下载tar包后解压用python setup.py install安装最新的pip即可

 

posted @ 2023-02-16 14:45  腹肌猿  阅读(73)  评论(0编辑  收藏  举报