Issue #448 resolved

Python3 Support

Steve Milner
created an issue

I did a quick search looking for this projects plans for python3 use and didn't find any information. Is there a plan to have a separate branch to release tarballs from or will there be a specific cut off date where pygments moves to python3 (and users should use 2to3 for now)?

Either way, it would be nice to see this in the FAQ or another location on the wiki.

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=537244

Thanks!

Comments (8)

  1. matt_hulse

    The FAQ says that Python 3 is supported but I receive the following error when attempting to import pygments in Python 3:

    File "/home/user/src/pygments/__init__.py", line 46
        except TypeError, err:
    

    From what I can tell, this should be:

        except TypeError as err:
    

    The same code occurs on line 70.

  2. matt_hulse

    I am running into several other issues in pygments as I am attempting to port a plugin that uses pygments from Python2 to Python3.

    Am I supposed to be using 2to3 or something like that?

  3. Georg Brandl repo owner

    @Andy: All released Pygments versions are Python 3 compatible with 2to3, which is automatically called by setup.py.

    Pygments 2.0, the current development version, will be single-source compatible (no 2to3) with 2.6+ and 3.3+.

  4. Andrew Kluger

    Thanks Georg. I don't know why, but on my Mac OS X Mavericks system with python3 installed via homebrew, this wasn't the case. After your comment I tried

    pip3 install --force-reinstall -U pygments
    

    and all was well.

  5. Marc Abramowitz

    So I was also getting this error when trying to pip install Pygments 1.6 into a python 3.3 virtualenv:

      File "/private/tmp/pygments-py33.venv/build/Pygments/pygments/__init__.py", line 46
        except TypeError, err:
                        ^
    SyntaxError: invalid syntax
    

    I scratched my head for a while wondering why 2to3 wasn't getting called.

    Eventually I realized by doing pip install -v Pygments that pip was picking up a wheel that I had built. Something seems to be wrong with that wheel because after removing it, pip install Pygments works fine.

    I mention this just in case anyone runs into this problem and goes searching and comes upon this issue.

  6. Log in to comment