Pycharm 报错 AttributeError: module 'pip' has no attribute 'main'

1.打开文件packaging_tool.py:

  D:\Program files\pycharm\PyCharm 2016.3.2\helpers\packaging_tool.py

2.添加导入:

  import pip._internal as pip_new 

3.修改参数

  修改前的代码为:  

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)
View Code

  修改后的代码:

def do_install(pkgs):
    try:
        import pip
    except ImportError:
        error_no_pip()
    return pip_new.main(['install'] + pkgs)


def do_uninstall(pkgs):
    try:
        import pip
    except ImportError:
        error_no_pip()
    return pip_new.main(['uninstall', '-y'] + pkgs)
View Code

猜你喜欢

转载自www.cnblogs.com/cuizhx/p/9976948.html