Can Python Requests library be used on Google App Engine?

Can I use Requests on Google App Engine? I think this library is perfect to create a REST client.


Install the requests-toolbelt library: https://github.com/sigmavirus24/requests-toolbelt

For App Engine it could be something like: pip install requests-toolbelt -t lib

(See: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library)

Then add:

from requests_toolbelt.adapters import appengine
appengine.monkeypatch()

In your main.py or equivalent.

Edit: this solution is now part of the official documentation: https://cloud.google.com/appengine/docs/python/issue-requests#issuing_an_http_request (in the REQUESTS tab)


Yes. On Google Appengine (version 1.9.18) requests version 2.3.0 works IN PRODUCTION (but not on SDK) if you have billing enabled, which enables sockets support.

Update: As of 31 Jan 2017 Requests is working in production with version 2.9.1 in production. However, it's not working with Google cloud SDK 141.0.0

requests on the Appengine SDK fails with all https:// requests:

  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

requests version 2.4.1 fails in production with:

  File "distlib/requests/adapters.py", line 407, in send
    raise ConnectionError(err, request=request)
  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

requests version 2.5.1 fails in production with:

  File "distlib/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

requests version 2.3.0 works in production, but may cause problems with Debians removed SSLv3 support in the SDK (requests 2.3.0 comes with its own now outdated urllib3). As workaround it is possible to delete the line containing PROTOCOL_SSLv3 in the source of request's urllib3 copy.

  'module' object has no attribute 'PROTOCOL_SSLv3'

Info on sockets support: https://cloud.google.com/appengine/docs/python/sockets/


Not yet but hopefully very soon. Support for GAE is being worked on - see issue #498 (App Engine Fixes).

Requests uses urllib3 which in turn uses httplib which is supported on GAE as a wrapper for urlfetch API. Although urllib3 uses some modules not available on GAE this usage is deliberately made optional so that urllib3 can be used on GAE.