データ ラボ ノートブックからビッグ クエリ API に接続するために、Python で次のコードを実行しています。
!pip install google-api-python-client==1.4.2 httplib2==0.9.2 oauth2client==1.5.2 pyasn1==0.1.9 pyasn1-modules==0.0.8 rsa==3.2.3 simplejson==3.8.1 six==1.10.0 uritemplate==0.6 wheel==0.24.0
import httplib2
import time
import datetime as dt
import sys
import subprocess
from googleapiclient import errors
from googleapiclient.discovery import build
from oauth2client.file import Storage
from oauth2client.client import GoogleCredentials
from googleapiclient.http import MediaFileUpload
import gcp.bigquery as bq
import pandas as pd
credentials = GoogleCredentials.get_application_default()
bigquery_service = build('bigquery', 'v2', credentials=credentials)
次のエラーが表示されます。
() 内の ImportError トレースバック (最新の呼び出しが最後)
----> 5 個の認証情報 = GoogleCredentials.get_application_default() 6 7 bigquery_service = build('bigquery', 'v2', credentials=credentials)
/usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in >get_application_default() 1202 """ 1203 return self -> 1204 1205 @property 1206 def serialization_data(self):
/usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in _get_implicit_credentials(cls) 1187 access_token、client_id、client_secret、refresh_token、1188 token_expiry、token_uri、user_agent、revoke_uri=revoke_uri) -> 1189 1190 def create_scoped_required(self): 1191 """この Credentials オブジェクトがスコープレスかどうか。
/usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in _implicit_credentials_from_gce() 1123 def _in_gce_environment(): 1124 """コードが Compute Engine 環境で実行されているかどうかを検出します。 -> 1125 1126戻り値: 1127 GCE 環境で実行している場合は true、それ以外の場合は false。
/usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in _get_application_default_credential_GCE() 1378 資格情報: 既知のファイルに保存される資格情報。1379 GoogleCredentials のインスタンスである必要があります -> 1380 well_known_file: 資格情報が保存されるファイルの名前。このパラメーターは、1382 テストのみに使用されることになっています。
/usr/local/lib/python2.7/dist-packages/oauth2client/gce.py in () 24 oauth2client._helpers から import _from_bytes 25 oauth2client import util ---> 26 from oauth2client.client import HttpAccessTokenRefreshError 27 from oauth2client.クライアントのインポート AssertionCredentials 28
ImportError: 名前 HttpAccessTokenRefreshError をインポートできません
私は何が欠けていますか?この Google 提供の例がデータ ラボで機能しないのはなぜですか?