一、pip安装报错Unable to locate finder for 'pip._vendor.distlib'

问题来源

python3.x在安装pillow和mysqlclient模块的时候报错,发现pip版本过低,但使用python -m pip install --upgrade pip更新执行时报错回滚

(env_izone) F:\izone>python -m pip install --upgrade pip
?[33mYou are using pip version 7.1.0, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.?[0m
Collecting pip
  Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
      Successfully uninstalled pip-7.1.0
  Rolling back uninstall of pip
?[31mException:
Traceback (most recent call last):
  File "F:\env\env_izone\lib\site-packages\pip\basecommand.py", line 223, in main
    status = self.run(options, args)
  File "F:\env\env_izone\lib\site-packages\pip\commands\install.py", line 299, in run
    root=options.root_path,
  File "F:\env\env_izone\lib\site-packages\pip\req\req_set.py", line 646, in install
    **kwargs
  File "F:\env\env_izone\lib\site-packages\pip\req\req_install.py", line 813, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "F:\env\env_izone\lib\site-packages\pip\req\req_install.py", line 1008, in move_wheel_files
    isolated=self.isolated,
  File "F:\env\env_izone\lib\site-packages\pip\wheel.py", line 449, in move_wheel_files
    generated.extend(maker.make(spec))
  File "F:\env\env_izone\lib\site-packages\pip\_vendor\distlib\scripts.py", line 323, in make
    self._make_script(entry, filenames, options=options)
  File "F:\env\env_izone\lib\site-packages\pip\_vendor\distlib\scripts.py", line 227, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "F:\env\env_izone\lib\site-packages\pip\_vendor\distlib\scripts.py", line 163, in _write_script
    launcher = self._get_launcher('t')
  File "F:\env\env_izone\lib\site-packages\pip\_vendor\distlib\scripts.py", line 302, in _get_launcher
    result = finder(distlib_package).find(name).bytes
  File "F:\env\env_izone\lib\site-packages\pip\_vendor\distlib\resources.py", line 297, in finder
    raise DistlibException('Unable to locate finder for %r' % package)
pip._vendor.distlib.DistlibException: Unable to locate finder for 'pip._vendor.distlib'
?[0m

问题解决

1.卸载当前pip

python -m pip uninstall pip setuptools

2.下载get-pip.py

打开链接https://bootstrap.pypa.io/get-pip.py,右键另存为py文件

3.运行get-pip.py安装pip

(env_izone) F:\izone>python get-pip.py
Collecting pip
  Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/54/28/c45d8b54c1339f9644b87663945e54a8503cfef59cf0f65b3ff5dd17cf64/setuptools-42.0.2-py2.py3-none-any.whl
Installing collected packages: pip, setuptools
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
      Successfully uninstalled pip-7.1.0
Successfully installed pip-19.3.1 setuptools-42.0.2

版权声明:如无特殊说明,文章均为本站原创,转载请注明出处

本文链接:http://zhangyanc.club/article/python-pip/

许可协议:署名-非商业性使用 4.0 国际许可协议