【发布时间】:2017-06-19 13:58:03
【问题描述】:
我正在尝试在 Python 环境中从 Bigquery 查询数据。
我使用服务帐户通过 Bigquery 网站上的 this step 创建了我的凭据,并使用了以下代码。
from google.cloud import bigquery
client = bigquery.Client()
SQLCommand = '''
Some sql command '''
query_results = client.run_sync_query(SQLCommand)
query_results.run()
但是,我遇到了以下错误,我不确定在哪里可以解决此问题。任何建议将不胜感激!
Traceback (most recent call last):
File "<ipython-input-11-88c61e8cf342>", line 1, in <module>
query_results.run()
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site- packages\google_cloud_bigquery-0.24.0-py2.7.egg\google\cloud\bigquery\query.py", line 364, in run
method='POST', path=path, data=self._build_resource())
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_cloud_core-0.24.1-py2.7.egg\google\cloud\_http.py", line 299, in api_request
headers=headers, target_object=_target_object)
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_cloud_core-0.24.1-py2.7.egg\google\cloud\_http.py", line 193, in _make_request
return self._do_request(method, url, headers, data, target_object)
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_cloud_core-0.24.1-py2.7.egg\google\cloud\_http.py", line 223, in _do_request
body=data)
File "build\bdist.win-amd64\egg\google_auth_httplib2.py", line 187, in request
self._request, method, uri, request_headers)
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_auth-1.0.1-py2.7.egg\google\auth\credentials.py", line 121, in before_request
self.refresh(request)
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_auth-1.0.1-py2.7.egg\google\oauth2\service_account.py", line 310, in refresh
request, self._token_uri, assertion)
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_auth-1.0.1-py2.7.egg\google\oauth2\_client.py", line 143, in jwt_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "c:\users\xxxx\appdata\local\continuum\anaconda\lib\site-packages\google_auth-1.0.1-py2.7.egg\google\oauth2\_client.py", line 104, in _token_endpoint_request
method='POST', url=token_uri, headers=headers, body=body)
File "build\bdist.win-amd64\egg\google_auth_httplib2.py", line 119, in __call__
raise exceptions.TransportError(exc)
TransportError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)
[1]: https://cloud.google.com/docs/authentication/getting-started
【问题讨论】:
-
只是想知道,您如何为客户端设置凭据?蟒蛇已经完成了吗?您是否将其导出到您的环境中?
-
是的,我通过 export GOOGLE_APPLICATION_CREDENTIALS=
在我的环境中导出它
标签: python-3.x ssl-certificate google-bigquery