pycharm安装第三方库报错

Pycharm导入第三方库报错:

AttributeError:module 'pip' has no attribute 'main'

pip 版本,10.0以上没有main()

解决办法一:考虑降个版本:python -m pip install --upgrade pip==9.0.3

解决办法二:   修改pycharman安装包helpers下面的packaging_tool.py文件

defdo_install(pkgs):

    try:

        importpip

    exceptImportError:

        error_no_pip()

    return pip.main(['install'] +pkgs)



defdo_uninstall(pkgs):

    try:

        importpip

    exceptImportError:

        error_no_pip()

return pip.main(['uninstall', '-y'] + pkgs)



修改为:

def do_install(pkgs):

    try:

        #import pip

        try:

            frompip._internal import main

        exceptException:

            frompip import main

    exceptImportError:

       error_no_pip()

    return main(['install'] + pkgs)



def do_uninstall(pkgs):

    try:

        #import pip

        try:

            frompip._internal import main

        exceptException:

            frompip import main

    exceptImportError:

       error_no_pip()

return main(['uninstall', '-y'] + pkgs)



修改完成之后,重装就OK了

你可能感兴趣的:(pycharm安装第三方库报错)