Python开发错误汇总

  • Post author:
  • Post category:python


错误信息:

pip install pandas 安装失败:

AttributeError: module ‘pip’ has no attribute ‘main’

解决办法:

/Applications/PyCharm.app/Contents/helpers/packaging_tool.py

修改do_install和do_uninstall

原来:
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)

错误信息:

You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the ‘pip install –upgrade pip’ command.

解决办法:

运行命令:python -m pip install –upgrade pip



版权声明:本文为sheshou2原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。