开发者

Error while installing Poster (Python Module)

开发者 https://www.devze.com 2022-12-12 00:27 出处:网络
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.

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-x8开发者_开发技巧6_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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消