zoukankan      html  css  js  c++  java
  • python pip报错pip._ vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

    AttributeError: module 'pip' has no attribute 'main报错

    • 找到安装目录下 helpers/packaging_tool.py文件,找到如下代码:
      
      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 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)


    • 在下载python库的时候,由于国内网络原因,python包的下载速度非常慢,查看pip 文档,只要在 pip的时候控制超时即可, 具体参数为 --default-timeout=100, 后面的时间可以自己指定。
    • 解决方法
    • pip --default-timeout=100 install gevent


  • 相关阅读:
    48. Rotate Image
    83. Remove Duplicates from Sorted List
    46. Permutations
    HTML5笔记
    18. 4Sum
    24. Swap Nodes in Pairs
    42. Trapping Rain Water
    Python modf() 函数
    Python min() 函数
    Python max() 函数
  • 原文地址:https://www.cnblogs.com/cheng10/p/11344883.html
Copyright © 2011-2022 走看看