The Pygments source files import each other like
from pygments.foo import bar. If you have a globally-installed Pygments, this'll import correctly. But if you also have a local version of Pygments in some project, the local version will end up importing from the global version, and then various things will fail.
(In particular, the type-check that occurs at https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/lexer.py?fileviewer=file-view-default#lexer.py-431 will fail, because lexers.py has imported the global version of
_TokenType, but my code is importing the local version of
token.py, whose instances are all derived from the local
_TokenType, so they fail the type-check.)
This can be easily fixed by using proper relative imports, like
from .foo import bar - this is how I fixed it in my local copy. I'm happy to submit a PR to switch everything to relative imports, if that would be accepted.
(You can see the failure, attendant stack-trace, and fix in https://github.com/tabatkins/highlighter/issues/5.)