当pip命令遇到No module named ‘pip._internal.cli’报错

问题描述

想给pip升级,出现如下错误:

➜  ~ pip3.6 -V
Traceback (most recent call last):
  File "/usr/local/bin/pip3.6", line 7, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli'

问题解决

  1. 用Vim修改pip3.6文件
    sudo vi /usr/local/bin/pip3.6
  2. from pip._internal.cli.main import main注释掉改成如下:
    #from pip._internal.cli.main import main
    from pip._internal import main