Skip to content

Commit 4cf26aa

Browse files
committed
handling GoogleCredentials import error
1 parent ac48104 commit 4cf26aa

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pandas/io/gbq.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def _test_google_api_imports():
5252
except:
5353
from apiclient.discovery import build # noqa
5454
from apiclient.errors import HttpError # noqa
55-
from oauth2client.client import GoogleCredentials # noqa
5655
from oauth2client.client import AccessTokenRefreshError # noqa
5756
from oauth2client.client import OAuth2WebServerFlow # noqa
5857
from oauth2client.file import Storage # noqa
@@ -193,7 +192,10 @@ def get_application_default_credentials(self):
193192
from googleapiclient.discovery import build
194193
except ImportError:
195194
from apiclient.discovery import build
196-
from oauth2client.client import GoogleCredentials
195+
try:
196+
from oauth2client.client import GoogleCredentials
197+
except ImportError:
198+
return None
197199

198200
try:
199201
credentials = GoogleCredentials.get_application_default()

pandas/io/tests/test_gbq.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def _test_imports():
8080
from apiclient.discovery import build # noqa
8181
from apiclient.errors import HttpError # noqa
8282

83-
from oauth2client.client import GoogleCredentials # noqa
8483
from oauth2client.client import OAuth2WebServerFlow # noqa
8584
from oauth2client.client import AccessTokenRefreshError # noqa
8685

@@ -157,12 +156,12 @@ def _check_if_can_get_correct_default_credentials():
157156
# from the environment the tests are running in.
158157
# See Issue #13577
159158
test_requirements()
160-
from oauth2client.client import GoogleCredentials
161159
try:
162160
from googleapiclient.discovery import build
163161
except ImportError:
164162
from apiclient.discovery import build
165163
try:
164+
from oauth2client.client import GoogleCredentials
166165
credentials = GoogleCredentials.get_application_default()
167166
bigquery_service = build('bigquery', 'v2', credentials=credentials)
168167
jobs = bigquery_service.jobs()

0 commit comments

Comments
 (0)