facebookads api在google cloud appengine中调用 - SSLError:无法连接到HTTPS URL,因为SSL模块不可用

时间:2017-06-08 21:30:11

标签: google-app-engine google-cloud-platform facebook-ads-api

我要求将facebookads数据拉入bigquery。我需要为appengine创建python脚本。

Python脚本独立工作正常,没有任何问题,并获得了所需的数据。当我试图从appengine调用相同的python脚本时收到以下错误。

请帮我解决以下错误。

错误讯息:

ERROR    2017-06-08 21:22:10,816 webapp2.py:1528] Can't connect to HTTPS URL because the SSL module is not available.
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "C:\Chaitu\Projects\fb\main.py", line 57, in get
    stats = ad_account.get_insights(params=params)
  File "C:\Chaitu\Projects\fb\facebookads\adobjects\FBAdAccount.py", line 78, in get_insights
    return request.execute()
  File "C:\Chaitu\Projects\fb\facebookads\api.py", line 653, in execute
    cursor.load_next_page()
  File "C:\Chaitu\Projects\fb\facebookads\api.py", line 797, in load_next_page
    params=self.params,
  File "C:\Chaitu\Projects\fb\facebookads\api.py", line 305, in call
    timeout=self._session.timeout
  File "C:\Chaitu\Projects\fb\requests\sessions.py", line 513, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Chaitu\Projects\fb\requests\sessions.py", line 623, in send
    r = adapter.send(request, **kwargs)
  File "C:\Chaitu\Projects\fb\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
SSLError: Can't connect to HTTPS URL because the SSL module is not available.
ERROR    2017-06-08 21:22:10,822 wsgi.py:279]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 267, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1519, in __call__
    response = self._internal_error(e)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "C:\Chaitu\Projects\fb\main.py", line 57, in get
    stats = ad_account.get_insights(params=params)
  File "C:\Chaitu\Projects\fb\facebookads\adobjects\FBAdAccount.py", line 78, in get_insights
    return request.execute()
  File "C:\Chaitu\Projects\fb\facebookads\api.py", line 653, in execute
    cursor.load_next_page()
  File "C:\Chaitu\Projects\fb\facebookads\api.py", line 797, in load_next_page
    params=self.params,
  File "C:\Chaitu\Projects\fb\facebookads\api.py", line 305, in call
    timeout=self._session.timeout
  File "C:\Chaitu\Projects\fb\requests\sessions.py", line 513, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Chaitu\Projects\fb\requests\sessions.py", line 623, in send
    r = adapter.send(request, **kwargs)
  File "C:\Chaitu\Projects\fb\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
**SSLError: Can't connect to HTTPS URL because the SSL module is not available.**
INFO     2017-06-08 17:22:12,344 module.py:809] default: "GET / HTTP/1.1" 500

1 个答案:

答案 0 :(得分:0)

AppEngine支持原生Python OpenSSL。您需要根据您正在使用的python版本修改app.yaml

如何在AppEngine服务中添加对OpenSSL的支持是documented here

v2.7

libraries:
- name: ssl
  version: 2.7

v2.7.11

libraries:
- name: ssl
  version: 2.7.11