zoukankan      html  css  js  c++  java
  • pycharm 问题:module 'pip' has no attribute 'main'

    
    

    更新pip之后,Pycharm安装package出现报错:module 'pip' has no attribute 'main'

    找到安装目录下 helpers/packaging_tool.py文件,找到如下代码:
     1 def do_install(pkgs):
     2     try:
     3         import pip
     4     except ImportError:
     5         error_no_pip()
     6     return pip.main(['install'] + pkgs)
     7  
     8  
     9 def do_uninstall(pkgs):
    10     try:
    11         import pip
    12     except ImportError:
    13         error_no_pip()
    14     return pip.main(['uninstall', '-y'] + pkgs)   
    15  
    修改为如下,保存即可。
     1  
     2 def do_install(pkgs):
     3     try:
     4         # import pip
     5         try:                                #修改位置1
     6             from pip._internal import main
     7         except Exception:
     8             from pip import main
     9     except ImportError:
    10         error_no_pip()
    11     return main(['install'] + pkgs)         #修改位置2
    12  
    13  
    14 def do_uninstall(pkgs):
    15     try:
    16         # import pip
    17         try:                                  #修改位置3
    18             from pip._internal import main
    19         except Exception:
    20             from pip import main
    21     except ImportError:
    22         error_no_pip()
    23     return main(['uninstall', '-y'] + pkgs)     #修改位置4
  • 相关阅读:
    Know more about RAC statistics and wait event
    再谈指针
    Manageing Undo Data
    SQL基础内容
    JavaScript高级程序设计(3版)笔记分享( ES5特性)
    HTML5布局篇( 总结 )
    温习 SQL 01(Z)
    Makefile
    SQLPLUS工具简介
    链接相关 & 预处理
  • 原文地址:https://www.cnblogs.com/zpw-1/p/9848164.html
Copyright © 2011-2022 走看看