Google App Engine httplib2 import Http 导致语法错误

Google App Engine httplib2 import Http results in Syntax Error

寻求有关 Google App Engine 的帮助。以下是我的代码中有问题的部分:

from __future__ import print_function
import webapp2
import jinja2
import csv
import os
from collections import namedtuple
from httplib2 import Http
from googleapiclient.discovery import build
from oauth2client import file, client, tools
import datetime
##code to do stuff

我 运行 遇到麻烦的地方是 "from httplib2 import Http" 行。我收到以下错误:

Traceback (most recent call last):
  File "/base/alloc/tmpfs/dynamic_runtimes/python27g/c3b7fd7c606f3aa7/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/alloc/tmpfs/dynamic_runtimes/python27g/c3b7fd7c606f3aa7/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/alloc/tmpfs/dynamic_runtimes/python27g/c3b7fd7c606f3aa7/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/k~fraseline2019/20181014t160622.413269158822473824/main.py", line 10, in <module>
    from httplib2 import Http
  File "/base/data/home/apps/k~fraseline2019/20181014t160622.413269158822473824/lib/httplib2/__init__.py", line 382
    print('%s:' % h, end=' ', file=self._fp)
                        ^
SyntaxError: invalid syntax

我的应用程序目录中有 httplib2 模块文件。我一直在谷歌上搜索,但似乎没有人遇到过这个问题 - 有人可以帮忙吗?

谢谢!

请阅读 MCVEs。看起来这个问题的 MCVE 是一行:

从 httplib2 导入 Http

我认为您的问题是您的 httplib2 模块缺少未来所需的导入。

from __future__ import print_function

未来的导入仅适用于它们出现的模块。没有它,在 2.7 中,人们会得到你得到的回溯。

>>> print(1, 2, end='')
  File "<stdin>", line 1
    print(1, 2, end='')
                   ^
SyntaxError: invalid syntax