Python: Syntax Error for imported module - 'codecs.py'
I'm using a script which imports some modules, one being codecs
. When the script is executed, I'll get a Traceback (most recent call last):
on the import codecs
line and SyntaxError: ('no viable alternative at input \'""\'', ('C:\\Python26\\lib\\codecs.py', 268, 17, ' return (b"", 0)\n'))
. This only occurs when I'm executing my own script which in turn executes the script which imports the codecs
module. If I directly execute the script through cmd, the error w开发者_StackOverflowill not occur.
which in turn executes the script which ...
How does it ‘execute’ the script? You mean an import? A subprocess call? Something else?
Because “no viable alternative at input...” is a distinctive ANTLR parser error, and CPython 2.6 doesn't use that.
Jython 2.5 does. But Jython shouldn't be trying to run the codecs
module from CPython 2.6. In this case it fails because of the syntax b""
for byte strings which is new in Python 2.6.
精彩评论