Pygments 导入 Lex 错误

Pygments import Lex error

我尝试使用以下代码导入 lex:

from pygments import lex

但它只返回了一个错误:

Traceback (most recent call last):
  File "D:\samp.py", line 1, in <module>
    from pygments import lex
  File "C:\Python32\lib\site-packages\pygments-2.0.2-py3.2.egg\pygments\__init__.py", line 37, in <module>
    from pygments.util import StringIO, BytesIO
  File "C:\Python32\lib\site-packages\pygments-2.0.2-py3.2.egg\pygments\util.py", line 226
    return u'[%s-%s]' % (unichr(a), unichr(b))
                    ^
SyntaxError: invalid syntax

(我在 IDLE 上使用 Python 3.2.3)

有解决办法吗?

似乎有人已经将此记录为错误 here

解析是-

Pygments 2.0 requires Python 3.3+.

你应该安装 Python 3.3 或更高版本,然后在上面安装 pygment。