【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法...

pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法

【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法..._第1张图片

 

 

解决方法:

在pycharm的安装目录下,找到helpers/packaging_tool.py文件,

找到对应的109行和192行。

也就是找到:

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:
        # import pip
        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:
        # import pip
        try:
            from pip._internal import main
        except Exception:
            from pip import main
    except ImportError:
        error_no_pip()
    return main(['uninstall', '-y'] + pkgs)

【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法..._第2张图片

 

 关闭保存,重启pycharm软件,继续刚刚的操作,问题即可解决

 

转载于:https://www.cnblogs.com/sxdcgaq8080/p/10234099.html

你可能感兴趣的:(开发工具,python)