【问题标题】:Error while installing Poster (Python Module)安装海报时出错(Python 模块)
【发布时间】:2009-11-23 04:52:32
【问题描述】:

我正在尝试安装 Chris Atlee's python Poster library,以便我可以在我的脚本中使用 HTTP POST 查询上传文件。

在 python 2.3 上,当我输入 # python setup.py install 时,我收到以下错误。安装继续,但我以后不能>>> import poster

byte-compiling build/bdist.linux-x86_64/egg/poster/encode.py to encode.pyc
  File "build/bdist.linux-x86_64/egg/poster/encode.py", line 112
    @classmethod
    ^
SyntaxError: invalid syntax
byte-compiling build/bdist.linux-x86_64/egg/poster/streaminghttp.py to streaminghttp.pyc
  File "build/bdist.linux-x86_64/egg/poster/streaminghttp.py", line 114
    newheaders = dict((k,v) for k,v in req.headers.items()
                              ^
SyntaxError: invalid syntax
byte-compiling build/bdist.linux-x86_64/egg/poster/__init__.py to __init__.pyc

任何指针?

【问题讨论】:

    标签: python post http-post httppostedfile http-post-vars


    【解决方案1】:

    Python 2.3 不支持装饰器(这就是@classmethod)或列表推导(这是第二个错误),所以你要么必须找到旧版本的海报,要么坚持使用 urllib /urllib2 用于执行 HTTP 工作。

    实际上,Poster 似乎是在 2008 年 7 月左右创建的,因此即使您能找到原始来源,也不太可能有支持 Python 2.3 的版本。您至少不能升级到最新的 Python 2.x 有什么特别的原因吗?

    【讨论】:

      猜你喜欢
      • 2011-06-06
      • 2015-07-16
      • 2014-10-13
      • 2016-11-29
      • 1970-01-01
      • 2012-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多