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

 

posted @ 2018-11-18 06:06  村西崔二  阅读(185)  评论(0编辑  收藏  举报