Using Requests module in Google App Engine

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Using Requests module in Google App Engine



I want to use the requests module in Google App Engine Python Runtime Environment.


requests



Quote from official Google Cloud docs:



You can use third-party libraries that are pure Python code with no C extensions, by copying the library into your application directory. If the third-party library is already built-in, bundled with the runtime, you can use the library without copying it into your app.



Third party libraries must be implemented as pure Python code with no C extensions. If copied to your application directory, they count towards file quotas because the library is uploaded to App Engine along with your application code.



requests isn't bundled with GAE, so I added it into my application folder according to the instructions.


requests



requests required a few other modules that don't come with GAE, so I added all of them to my application folder:


requests


certifi


chardet


idna


urllib3



Another problem came up. My request goes to the Stack Exchange API, which uses HTTPS. Here's the error:


SSLError: HTTPSConnectionPool(host='api.stackexchange.com', port=443): Max retries exceeded with url: /2.2/1?site=stackoverflow (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))



The ssl module is built into the GAE Python runtime, so I put the following in app.yaml:


ssl


app.yaml


libraries:
- name: webapp2
version: latest

- name: ssl
version: latest



It didn't work. I got the same error as before. I copied the SSL module folder into my application directory and did import ssl in main.py, but now it throws an exception asking for yet another module to be installed:


import ssl


main.py


File "/Users/williamqin/Projects/stackpromo/ssl/__init__.py", line 61, in <module>
import _ssl2 # if we can't import it, let the error propagate
ImportError: No module named _ssl2



I searched all over the web for the _ssl2 Python module, but I couldn't find it anywhere!


_ssl2



How do I properly use the requests module in Google App Engine?


requests









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived