Skip to content

Instantly share code, notes, and snippets.

@hacha
Created June 28, 2015 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hacha/1460566d147056363aa5 to your computer and use it in GitHub Desktop.
Save hacha/1460566d147056363aa5 to your computer and use it in GitHub Desktop.
GoogleAppEngineでPythonからSpreadSheetにアクセスしたい
ちょろっとしたことがやりたいだけなのに、やたらとつまづいているので一旦状況を整理する。
Python触るの初めてで、勝手の分からんからつまづいているんだと思う。
やりたいことは下記にあることまんま。
GoogleAppEngineでPythonからSpreadSheetにアクセスして、内容を読む。それだけ。
http://qiita.com/koyopro/items/d8d56f69f863f07e9378
自分が作業している環境
MacOS 10.10.3
Python 2.7.6
上記リンクの4あたりまでは準備できたが、いざローカルで動かそうと下記のエラーが出る。
####
Error: 500 Internal Server Error
Sorry, the requested URL 'http://localhost:8080/test' caused an error:
Internal Server Error
Exception:
CryptoUnavailableError('No crypto library available',)
Traceback:
Traceback (most recent call last):
File "/Users/username/projects/appname/lib/bottle.py", line 764, in _handle
return route.call(**args)
File "/Users/username/projects/appname/lib/bottle.py", line 1575, in wrapper
rv = callback(*a, **ka)
File "/Users/username/projects/appname/main.py", line 27, in test
credentials = SignedJwtAssertionCredentials(client_email, private_key, scope=scope)
File "/Users/username/projects/appname/lib/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/username/projects/appname/lib/oauth2client/client.py", line 1504, in __init__
_RequireCryptoOrDie()
File "/Users/username/projects/appname/lib/oauth2client/client.py", line 1458, in _RequireCryptoOrDie
raise CryptoUnavailableError('No crypto library available')
CryptoUnavailableError: No crypto library available
####
ふぅむ、どうもライブラリがないっぽいようなこと言われる。
「CryptoUnavailableError('No crypto library available',)」でググると、なんかPyOpenSSLを入れろってことっぽい。
で「pip install PyOpenSSL」すると
Requirement already satisfied (use --upgrade to upgrade): PyOpenSSL in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
とくる。
え?既にあるってこと?
となるとAppLauncherで動作する際にライブラリへのパスが通ってない的なことなのか?
そうであるかどうかの確認方法がよく分からんのと、そうであった場合にどうすりゃいいのかがよく分からん。
しかしとりあえず環境の問題ってことは、GAE上では動くのかな?と試しにdeployしてみる。
すると下記エラーが出たが、ひとまず認証自体は通ってるっぽい。
####
Error: 500 Internal Server Error
Sorry, the requested URL 'https://appname.appspot.com/test' caused an error:
Internal Server Error
Exception:
ParseError('no element found: line 1, column 0',)
Traceback:
Traceback (most recent call last):
File "/base/data/home/apps/s~appname/1.385245706331392292/lib/bottle.py", line 764, in _handle
return route.call(**args)
File "/base/data/home/apps/s~appname/1.385245706331392292/lib/bottle.py", line 1575, in wrapper
rv = callback(*a, **ka)
File "/base/data/home/apps/s~appname/1.385245706331392292/main.py", line 39, in test
sheets = client.get_worksheets("xxxxxx") # スプレッドシートIDを指定
File "/base/data/home/apps/s~appname/1.385245706331392292/lib/gdata/spreadsheets/client.py", line 108, in get_worksheets
**kwargs)
File "/base/data/home/apps/s~appname/1.385245706331392292/lib/gdata/client.py", line 640, in get_feed
**kwargs)
File "/base/data/home/apps/s~appname/1.385245706331392292/lib/gdata/client.py", line 278, in request
version=get_xml_version(self.api_version))
File "/base/data/home/apps/s~appname/1.385245706331392292/lib/atom/core.py", line 520, in parse
tree = ElementTree.fromstring(xml_string)
File "<string>", line 125, in XML
ParseError: no element found: line 1, column 0
####
う〜ん、スプレッドシートIDは合ってるはずなんだけど、これはどういうことなのか??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment