Cron工作在google云应用引擎中失败了firebase

时间:2017-07-05 17:23:06

标签: google-app-engine firebase cron cron-task

我已经习惯在firebase博客链接下方执行一个关于firebase功能的谷歌云应用引擎上的cron作业,但我收到以下错误。

Firebase Blog link

请帮助..

22:47:33.468
 (/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/s~updateroom-1a8fe/20170705t224250.402458509646721682/main.py", line 18, in <module>
    import pubsub_utils
  File "/base/data/home/apps/s~updateroom-1a8fe/20170705t224250.402458509646721682/pubsub_utils.py", line 23, in <module>
    import httplib2
  File "./lib/httplib2/__init__.py", line 352
    print('%s:' % h, end=' ', file=self._fp)
                        ^
SyntaxError: invalid syntax

1 个答案:

答案 0 :(得分:4)

print('%s:' % h, end=' ', file=self._fp)有效python3,但无效python2

您可以在将来导入以在python2中使用此语法:

from __future__ import print_function

或使用旧的print语法。

更新

回顾这一点,我注意到有问题的代码行在库代码中:./lib/httplib2/__init__.py

所以问题是你的httplib2安装是python3版本而不是python2版本。

您可以尝试重新安装您的托管软件包以解决此问题;命令将是

pip install -r <name-of-your-vendored-requirements-file> -t lib

确保使用正确版本的pippip --version应指向python2安装中的位置。