zoukankan      html  css  js  c++  java
  • module 'pip' has no attribute 'main'

    Pycharm安装package出现报错:module 'pip' has no attribute 'main'
     
    Traceback (most recent call last):
    File "D:Program FilesJetBrainsPyCharm Community Edition 2017.3.1helperspackaging_tool.py", line 192, in main
    retcode = do_install(pkgs)
    File "D:Program FilesJetBrainsPyCharm Community Edition 2017.3.1helperspackaging_tool.py", line 109, in do_install
    return pip.main(['install'] + pkgs)
    AttributeError: module 'pip' has no attribute 'main'
     
    参考解决:https://blog.csdn.net/yup1212/article/details/80047326
    第104行
    原文:
    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 pip.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 pip.main(['uninstall', '-y'] + pkgs)

    还是出现报错

    参考链接:https://segmentfault.com/q/1010000014743128
    解决方案:之前更改packaging_tool.py时少改了一处。最后return处要把pip删掉。
    最后修改为:
    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)
  • 相关阅读:
    [USACO11JAN]Roads and Planes G【缩点+Dij+拓补排序】
    Cheatsheet: 2015 05.01 ~ 05.31
    Cheatsheet: 2015 04.01 ~ 04.30
    Cheatsheet: 2015 03.01 ~ 03.31
    Cheatsheet: 2015.02.01 ~ 02.28
    Cheatsheet: 2015 01.01~ 01.31
    Cheatsheet: 2014 12.01 ~ 12.31
    Cheatsheet: 2014 11.01 ~ 11.30
    Cheatsheet: 2014 10.01 ~ 10.30
    Cheatsheet: 2014 09.01 ~ 09.30
  • 原文地址:https://www.cnblogs.com/kunkunZeng/p/9114119.html
Copyright © 2011-2022 走看看