【问题标题】:Httplib2 invalid syntax error with [python3.6][python3.6] 的 Httplib2 无效语法错误
【发布时间】:2019-03-07 22:23:49
【问题描述】:

我很久以前用 python3 构建应用程序。 不幸的是,这些天我的电脑坏了,我的 ubuntu 服务器发生了一些事情,不再使用,所以我重新配置它并从我的 github repo 克隆我的 python 应用程序,并在之前通过相同的步骤部署,除了一些依赖项的更新。 然后我收到错误消息。 我知道这是关于 python 2 和 3 的兼容性问题。但是我该如何解决呢?

[Thu Mar 07 16:07:12.139598 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637]   File "/var/www/ItemCatalogApp/venv/lib/python3.6/site-packages/httplib2/__init__.py", line 462
[Thu Mar 07 16:07:12.139604 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637]     print("%s:" % h, end=" ", file=self._fp)
[Thu Mar 07 16:07:12.139608 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637]                         ^
[Thu Mar 07 16:07:12.139612 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637] SyntaxError: invalid syntax

【问题讨论】:

  • 您以某种方式使用 Python 2.x 安装中的 Python 3.x 模块。安装 3.x(如果您还没有安装它),并使用它显式运行您的程序。

标签: python python-3.x httplib httplib2


【解决方案1】:

我怀疑您是在 Python 2 中运行此代码,而不是 Python 3。

end=file= 在 Python 2 中无效,除非您的程序顶部有 from __future__ import print_function

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 1970-01-01
    相关资源
    最近更新 更多