La solicitud GET que resulta en el objeto VerifiedHTTPSConnection no tiene ningún atributo ‘_tunnel_host’

Estoy utilizando la biblioteca de solicitudes de python para realizar solicitudes HTTP GET a una API alojada en GAE. La versión de requests==2.20.0 es requests==2.20.0 y se instala a través de pip utilizando un entorno virtual.

Se ha informado que el problema se debe a una versión obsoleta de python. Estoy ejecutando la última versión de python 2 (2.7.15).

Aquí está el código cortado:

 endpoint_url = API_URL + "some/endpoint/%s" % some_variable response = requests.get(url=endpoint_url) return response.text 

Y aquí está la stack:

 Traceback (most recent call last): File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/Users/rhys/Desktop/Projects/git-r repositories/MitigatingCircumstancesTracker/lib/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/main.py", line 83, in login response = requests.get(url=endpoint_url) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/requests/api.py", line 75, in get return request('get', url, params=params, **kwargs) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/requests/api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/requests/sessions.py", line 524, in request resp = self.send(prep, **send_kwargs) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/requests/sessions.py", line 637, in send r = adapter.send(request, **kwargs) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/requests/adapters.py", line 449, in send timeout=timeout File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/urllib3/connectionpool.py", line 343, in _make_request self._validate_conn(conn) File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/urllib3/connectionpool.py", line 839, in _validate_conn conn.connect() File "/Users/rhys/Desktop/Projects/git- repositories/MitigatingCircumstancesTracker/lib/urllib3/connection.py", line 304, in connect if self._tunnel_host: AttributeError: 'VerifiedHTTPSConnection' object has no attribute '_tunnel_host' 

Versión de Python de 'python --version' 2.7.15

requisitos.txt:

 bcrypt==3.1.4 certifi==2018.10.15 cffi==1.11.5 chardet==3.0.4 Click==7.0 Flask==1.0.2 idna==2.7 itsdangerous==0.24 Jinja2==2.10 MarkupSafe==1.0 pycparser==2.19 requests==2.20.0 six==1.11.0 urllib3==1.24 Werkzeug==0.14.1 

Yo tuve el mismo problema. En mi caso, aparentemente estaba relacionado con la incapacidad de Google App Engine para trabajar con solicitudes en un entorno de desarrollo local (con SDK). AppEngineAdapter request_toolbelt es necesario. Trabajó para mí después.

Para corregir solicitudes para trabajar con Google App Engine pero también permitir que mi aplicación se ejecute fuera de GAE, agregué el siguiente código:

 try: from google.appengine.api import urlfetch from requests_toolbelt.adapters import appengine appengine.monkeypatch() except ImportError: pass