Question

I've just updated Stripe API library to the latest version and it stopped working on Google AppEngine due to fact that GAE is blocking imports of some packages such as sockets and SSL.

ERROR    2014-05-10 09:55:16,576 base.py:215] Internal Server Error: /api/billing/subscribe_to_paid_plan/stripe
    Traceback (most recent call last):
...
     File "/src/classes/billing/api_views.py", line 3, in <module>
        import stripe
      File "/src/stripe/__init__.py", line 16, in <module>
        from stripe.resource import (  # noqa
      File "/src/stripe/resource.py", line 5, in <module>
        from stripe import api_requestor, error, util
      File "/src/stripe/api_requestor.py", line 5, in <module>
        import ssl
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 60, in <module>
        import _ssl             # if we can't import it, let the error propagate
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 852, in load_module
        raise ImportError('No module named %s' % fullname)
    ImportError: No module named _ssl

Are there any chances to make it working on Google AppEngine?

Was it helpful?

Solution

You need to enable SSL by adding the following to your app.yaml:

libraries:
- name: ssl
  version: latest

EDIT: the bug below hasn't been fixed but I contributed a patch to the stripe python bindings to get around it.

There is currently a bug in the app engine dev server (It is on my to do list to try and fix it) which can be circumvented by doing the following:

add "_ssl" and "_socket" keys to the dictionary _WHITE_LIST_C_MODULES in /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py

Replace the socket.py file provided by google in /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/dis27 from the socket.py file from your Python framework.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top