Pycharm问题:module 'pip' has no attribute 'main'
更新pip之后(pip 10 版本之后),Pycharm安装package出现报错:module 'pip' has no attribute 'main'
解决办法如下:
找到Pycharm安装目录下的 helpers/packaging_tool.py 文件找到如下代码:
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)
本文来自博客园, 作者:Star-Hitian, 转载请注明原文链接:https://www.cnblogs.com/Star-Haitian/p/10275651.html