1

gspread を使用してアプリケーションをスプレッドシートに接続しています。そのために次のコードを使用しています

import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials

json_key = json.load(open('service_account.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
gc = gspread.authorize(credentials)
sheet = gc.open('Order Database').sheet1

この同じコードをアイドル状態で使用してスプレッドシートにアクセスしたときは問題なく動作しましたが、Google App Engine を使用しているアプリケーションのコードで使用したとき、アプリケーションを実行してこのエラーが発生したページ

ERROR    2015-09-14 08:49:44,263 wsgi.py:263] 
Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/Users/mbp13inch/Documents/Workspace/ehscanteen/main.py", line 15, in <module>
    db = Database()
  File "/Users/mbp13inch/Documents/Workspace/ehscanteen/server.py", line 10, in __init__
    credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
  File "/Users/mbp13inch/Documents/Workspace/ehscanteen/lib/oauth2client/util.py", line 142, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/mbp13inch/Documents/Workspace/ehscanteen/lib/oauth2client/client.py", line 1622, in __init__
    _RequireCryptoOrDie()
  File "/Users/mbp13inch/Documents/Workspace/ehscanteen/lib/oauth2client/client.py", line 1573, in _RequireCryptoOrDie
    raise CryptoUnavailableError('No crypto library available')
CryptoUnavailableError: No crypto library available

プロジェクトディレクトリにライブラリを正常にインストールしました:

pip install -t lib PyOpenSSL
pip install -t lib gspread
pip install -t lib oauth2client
pip install -t lib cryptography 

それぞれに追加しようとし--upgradeましたが、すべて正常にインストールされましたが、同じエラーが発生しました

私が何か間違っているかどうか教えてください。どうすればこの問題を解決できますか?

前もって感謝します。

4

1 に答える 1

1

わかりました、私はついに問題を解決しました。実際に必要だったのは、次を に追加することだけでしたapp.yaml

libraries:
- name: pycrypto
  version: "latest"
于 2015-09-14T14:41:24.733 に答える