在使用pycharm,升级pip后,包 module 'pip' has no attribute 'main' 这个错误,
解决办法
1、降级
2、修改安装目录下,helpers目录下的packaging_tool.py文件
def do_install(pkgs):
try:
#import pip,这是原来的
try:
from pip._internal import main
except ImportError:
from pip import main
except ImportError:
error_no_pip()
#return pip.main(['install'] + pkgs)
return main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
#import pip
try:
from pip._internal import main
except ImportError:
from pip import main
except ImportError:
error_no_pip()
#return pip.main(['uninstall', '-y'] + pkgs)
return main(['uninstall', '-y'] + pkgs)
修改这个后,还会遇到
name 'pip' is not defined
还要修改 return 部分