安装 Poster(Python 模块)时出错
我正在尝试安装 Chris Atlee 的 python 海报库,以便我可以使用 HTTP POST 上传文件从我的脚本中查询。
在 python 2.3 上,当我输入 # python setup.py install
时,出现以下错误。安装继续,但我无法 >>>稍后导入海报
。
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
有什么指点吗?
I'm trying to install Chris Atlee's python Poster library so I can upload a file using a HTTP POST query from within my script.
On python 2.3, when I type # python setup.py install
, I get the following error. The install continues, but I can't >>> import poster
later on.
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
Any pointers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Python 2.3 不支持装饰器(这就是 @classmethod)或列表推导式(这是第二个错误),所以你要么必须找到旧版本的 Poster,要么坚持使用 urllib/urllib2做你的 HTTP 工作。
事实上,Poster 看起来像是 2008 年 7 月左右创建的,所以即使你能找到原始来源,也不太可能有支持 Python 2.3 的版本。有什么特殊原因导致您无法至少升级到最新的 Python 2.x 吗?
Python 2.3 didn't have support for decorators (that's what @classmethod is) or list comprehensions (which is the second error), so you're either going to have to find an older version of Poster, or stick with urllib/urllib2 for doing your HTTP work.
Actually, it looks like Poster was created around July, 2008, so there's unlikely to be a version that supports Python 2.3 even if you could find the original source. Any particular reason you can't upgrade to the latest Python 2.x at least?