我正在尝试安装Chris Atlee's python Poster library,这样我就可以在我的脚本中使用HTTP POST查询上传文件。
在Python2.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有什么建议吗?
发布于 2009-11-23 12:55:59
Python 2.3不支持装饰符(这就是@classmethod )或列表理解(这是第二个错误),所以你要么找一个旧版本的Poster,要么坚持使用urllib/urllib2来做HTTP工作。
实际上,Poster看起来是在2008年7月左右创建的,所以即使你能找到原始源代码,也不太可能有支持Python2.3的版本。至少不能升级到最新的Python 2.x有什么特别的原因吗?
https://stackoverflow.com/questions/1781158
复制相似问题