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了