module 'pip' has no attribute 'main'
Posted 坤坤^_^
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了module 'pip' has no attribute 'main'相关的知识,希望对你有一定的参考价值。
Pycharm安装package出现报错:module \'pip\' has no attribute \'main\'
Traceback (most recent call last):
File "D:\\Program Files\\JetBrains\\PyCharm Community Edition 2017.3.1\\helpers\\packaging_tool.py", line 192, in main
retcode = do_install(pkgs)
File "D:\\Program Files\\JetBrains\\PyCharm Community Edition 2017.3.1\\helpers\\packaging_tool.py", line 109, in do_install
return pip.main([\'install\'] + pkgs)
AttributeError: module \'pip\' has no attribute \'main\'
参考解决:https://blog.csdn.net/yup1212/article/details/80047326
第104行
原文:
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 pip.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 pip.main([\'uninstall\', \'-y\'] + pkgs)
还是出现报错
参考链接:https://segmentfault.com/q/1010000014743128
解决方案:之前更改packaging_tool.py时少改了一处。最后return处要把pip删掉。
最后修改为:
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)
以上是关于module 'pip' has no attribute 'main'的主要内容,如果未能解决你的问题,请参考以下文章
解决pycharm问题:module 'pip' has no attribute 'main'
Pycharm问题:module 'pip' has no attribute 'main'
module 'pip' has no attribute 'main'
解决pycharm问题:module 'pip' has no attribute 'main'
pycharm安装第三方库失败module 'pip' has no attribute 'main'
Jupiter 页面环境下使用pip无法安装(AttributeError: module 'pip' has no attribute 'main')