“ImportError: No module named _ssl” with dev_appserver.py from Google App Engine

后端 未结 7 1896
误落风尘
误落风尘 2020-11-27 13:55

Background

\"In the Python runtime, we\'ve added support for the Python SSL Library, so you can now open secure connections to remote servic

相关标签:
7条回答
  • The solution by jmg works, but instead of changing the sdk files, you could monkey patch the relevant modules.

    Just put something like this on the beginning of your project setup.

    # Just taking flask as an example
    app = Flask('myapp')
    
    if environment == 'DEV':
        import sys
    
        from google.appengine.tools.devappserver2.python import sandbox
        sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
    
        from lib import copy_of_stdlib_socket.py as patched_socket
    
        sys.modules['socket'] = patched_socket
        socket = patched_socket
    
    0 讨论(0)
提交回复
热议问题