Skip to content

Latest commit

 

History

History
executable file
·
82 lines (60 loc) · 1.88 KB

File metadata and controls

executable file
·
82 lines (60 loc) · 1.88 KB

Problems of Python

1. PyCharm:AttributeError: module 'pip' has no attribute 'main'

  • 解决步骤

    • 打开/Applications/PyCharm.app/Contents/helpers/packaging_tool.py

    • 修改do_install和do_uninstall

      原来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)

2. 安装pyspider失败,提示PycURL how to specify the SSL backend manually.

3. 运行pyspider提示async=True, get_object=False, no_input=False

  • 因为async和await从python3.7开始已经加入保留关键字中,参考What's New Python3.7,所以async和await不能作为函数的参数名
  • 需要降低python版本至3.6