简体   繁体   English

安装海报时出错(Python模块)

[英]Error while installing Poster (Python Module)

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. 我正在尝试安装Chris Atlee的python Poster库,以便可以从脚本内使用HTTP POST查询上传文件。

On python 2.3, when I type # python setup.py install , I get the following error. 在python 2.3上,当我键入# python setup.py install ,出现以下错误。 The install continues, but I can't >>> import poster later on. 安装将继续,但是稍后无法>>> 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

Any pointers? 有指针吗?

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. Python 2.3不支持装饰器(@classmethod就是这样)或列表解析(这是第二个错误),因此您要么必须找到较旧版本的Poster,要么坚持使用urllib / urllib2做您的HTTP工作。

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. 实际上,Poster看起来像是在2008年7月左右创建的,因此即使您找到原始来源,也不大可能有支持Python 2.3的版本。 Any particular reason you can't upgrade to the latest Python 2.x at least? 您至少不能升级到最新的Python 2.x的任何特殊原因?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM