Python安装插件时报错:Traceback (most recent call last):AttributeError: module ‘pip’ has no attribute ‘main’

广告位

安装插件beautifulsoup4时遇到如下问题: Traceback (most recent call …

安装插件beautifulsoup4时遇到如下问题:

Traceback (most recent call last):
File “D:softPyCharm 2017.3.3helperspackaging_tool.py”, line 192, in main
retcode = do_install(pkgs)
File “D:softPyCharm 2017.3.3helperspackaging_tool.py”, line 109, in do_install
return pip.main([‘install’] + pkgs)
AttributeError: module ‘pip’ has no attribute ‘main’

Python安装插件时报错:Traceback (most recent call last):AttributeError: module 'pip' has no attribute 'main'
根据提示的路径去修改文件:
未修改前:

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     # except ImportError:     #     error_no_pip()     # return pip.main(['install'] + pkgs)     try:         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     # except ImportError:     #     error_no_pip()     # return pip.main(['uninstall', '-y'] + pkgs)     try:         try:             from pip._internal import main         except Exception:             from pip import main     except ImportError:         error_no_pip()     return main(['uninstall', '-y'] + pkgs)  

修改后再次添加插件即可成功
Python安装插件时报错:Traceback (most recent call last):AttributeError: module 'pip' has no attribute 'main'

陈晨数据工程师

关于作者: 陈晨数据工程师

为您推荐