def do_install(pkgs):
try:
import pip
except ImportError:
error_no_pip()
return pip.main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
import pip
except ImportError:
error_no_pip()
return pip.main(['uninstall', '-y'] + pkgs)
修改后:
def do_install(pkgs):
try:
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
try:
from pip_internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['uninstall', '-y'] + pkgs)
3.保存后再次尝试
4.若出现“inconsistent use of tabs and spaces in indentation”
这个报错就是混用了tab和4个空格造成的,检查代码,要不全部用tab,要不全部用4个空格