安装插件beautifulsoup4时遇到如下问题:
Traceback (most recent call last):
File “D:\soft\PyCharm 2017.3.3\helpers\packaging_tool.py”, line 192, in main
retcode = do_install(pkgs)
File “D:\soft\PyCharm 2017.3.3\helpers\packaging_tool.py”, line 109, in do_install
return pip.main([‘install’] + pkgs)
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)
修改后再次添加插件即可成功