安装Poster(Python模块)时出错

时间:2009-11-23 04:52:32

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

我正在尝试安装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

任何指针?

1 个答案:

答案 0 :(得分:1)

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

实际上,看起来海报是在2008年7月左右创建的,所以即使你能找到原始资源,也不太可能有支持Python 2.3的版本。任何特殊原因你至少无法升级到最新的Python 2.x?