Pycharm安装包过程出现问题的解决办法:module 'pip' has no attribute 'main'

1.找到helpers文件夹下的packaging_tool.py

 

2.修改该文件104行至117行内容

修改前

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个空格

 

 

猜你喜欢

转载自www.cnblogs.com/tora428/p/9172252.html