【pycharm】pycharm上安裝tensorflow,報錯:AttributeError: module 'pip' has no attribute 'main' 解決方法
阿新 • • 發佈:2019-01-07
pycharm上安裝tensorflow,報錯:AttributeError: module 'pip' has no attribute 'main' 解決方法
解決方法:
在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 mainexcept 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 mainexcept ImportError: error_no_pip() return main(['uninstall', '-y'] + pkgs)
關閉儲存,重啟pycharm軟體,繼續剛剛的操作,問題即可解決