2017-06-19 23 views
0

私はPython環境内でBigqueryからデータを照会しようとしています。SSL:CERTIFICATE_VERIFY_FAILED with 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() 

ただし、次のエラーが発生していますが、この問題を解決するための場所を特定できません。どんな提案もありがとう!

私は、これはBigQueryの具体的なものではなく、この質問に対する答えの一つが関連する可能性が疑われる
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 
+0

クライアントの資格情報はどのように設定していますか?それはすでにアナコンダによって行われていますか?あなたの環境でエクスポートしましたか? –

+0

はい、エクスポートすることで自分の環境にエクスポートしようとしていますGOOGLE_APPLICATION_CREDENTIALS = <パス_to_service_account_file> – user4279562

答えて

0

urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error

基本的には、ルート証明書がいくつかと一緒にデフォルトでインストールされていませんPythonのバージョンであり、インストール後の手順の一環としてこれを行う必要があります。ルート証明書がなければ、HTTPSクライアントはリモートサーバーのIDを確認する方法がありません。

ショートバージョン、あなたはおそらく(リンク質問から取られた)これを実行する必要があります。

「のReadMeはあなただけの認証取得をインストールし、このインストール後のスクリプトを実行しています:/アプリケーション/ Pythonの\ 3.6/Install \ Certificates.command "

+0

そうは思わないです。私はPython 2.7を使用しており、certifiがインストールされています。 Windowsでは、証明書は〜lib \ site-packages \ certifi \ cacert.pemに格納されています。 BigQueryからも証明書をダウンロードする必要がありますか? – user4279562

関連する問題