Problems_Python

Problems of Python

1. PyCharm:AttributeError: module ‘pip’ has no attribute ‘main’

  • 解决步骤

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

    • 修改do_install和do_uninstall

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      原来:
      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

4. Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using.

1
2
3
sudo pip3 uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib;export CPPFLAGS=-I/usr/local/opt/openssl/include;pip install pycurl --compile --no-cache-dir
Author: entercoder1993
Link: http://entercoder.com/2018/09/22/Problems-Python/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.