Pycharm安装模块报错:module 'pip' has no attribute 'main'

Pycharm安装报错module ‘pip’ has no attribute ‘main’

当安装需要的包时,有时候会遇到pycharm报出这样的错误"module ‘pip’ has no attribute ‘main’"
我们需要修改pycharm的文件:
文件路径为JetBrains\PyCharm Community Edition 2017.3.3\helpers\packaging_tool.py

头部加上 “import pip._internal as pip_new”
然后修改文件中下面两行:
return pip.main([‘install’] + pkgs)
return pip.main([‘uninstall’, ‘-y’] + pkgs)
修改为:
return pip_new.main([‘install’] + pkgs)
return pip_new.main([‘uninstall’, ‘-y’] + pkgs)
这样再安装时就不会报错了

你可能感兴趣的:(pycharm学习)