AttributeError:「モジュール」オブジェクトには属性「GoogleCredentials」がありません
ローカルホストで実行されている appengine アプリがあります。実行するいくつかのテストがあり、remote_api を使用して db 値を確認したいと考えています。訪問してremote_apiにアクセスしようとすると:
'http://127.0.0.1:8080/_ah/remote_api'
私は得る:
"This request did not contain a necessary header"
しかし、ブラウザで動作します。
テストから remote_api を呼び出そうとすると、
remote_api_stub.ConfigureRemoteApiForOAuth('localhost:35887','/_ah/remote_api')
エラーが発生します:
Error
Traceback (most recent call last):
File "/home/dan/src/gtup/test/test_users.py", line 38, in test_crud
remote_api_stub.ConfigureRemoteApiForOAuth('localhost:35887','/_ah/remote_api')
File "/home/dan/Programs/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 747, in ConfigureRemoteApiForOAuth
credentials = client.GoogleCredentials.get_application_default()
AttributeError: 'module' object has no attribute 'GoogleCredentials'
Googleクラウド全体を再インストールしようとしましたが、うまくいきませんでした.
client.py を開くと
google-cloud-sdk/platform/google_appengine/lib/google-api-python-client/oauth2client/client.py
これは remote_api_stub.py で使用されていますが、内部に GoogleCredentials クラスがないことがわかります。
GoogleCredentials クラスは存在しますが、次の場所にある他の client.py ファイル内にあります。
google-cloud-sdk/platform/google_appengine/lib/oauth2client/oauth2client/client.py
google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/client.py
google-cloud-sdk/platform/bq/third_party/oauth2client/client.py
google-cloud-sdk/lib/third_party/oauth2client/client.py
私の app.yaml は次のようになります。
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: webapp2
version: latest
builtins:
- remote_api: on
handlers:
- url: /.*
script: main.app
これは appengine 内の間違ったインポート/バグですか? または、ユニットテスト内で remote_api を使用するために何か間違ったことをしていますか?