matplotlib/matplotlib · error · ValueError
Failed to parse {path} as Postscript encoding
Error message
Failed to parse {path} as Postscript encoding What it means
Error "Failed to parse {path} as Postscript encoding" thrown in matplotlib/matplotlib.
Source
Thrown at lib/matplotlib/dviread.py:1248
The format supported by this function is a tiny subset of PostScript.
Parameters
----------
path : `os.PathLike`
Returns
-------
list
The nth list item is the PostScript glyph name of the nth glyph.
"""
no_comments = re.sub("%.*", "", Path(path).read_text(encoding="ascii"))
array = re.search(r"(?s)\[(.*)\]", no_comments).group(1)
lines = [line for line in array.split() if line]
if all(line.startswith("/") for line in lines):
return [line[1:] for line in lines]
else:
raise ValueError(f"Failed to parse {path} as Postscript encoding")
class _LuatexKpsewhich:
@cache # A singleton.
def __new__(cls):
self = object.__new__(cls)
self._proc = self._new_proc()
return self
def _new_proc(self):
return subprocess.Popen(
["luatex", "--luaonly", str(cbook._get_data_path("kpsewhich.lua"))],
# mktexpk logs to stderr; suppress that.
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
# Store generated pk fonts in our own cache.
env={"MT_VARTEXFONTS": str(Path(mpl.get_cachedir(), "vartexfonts")),
**os.environ})
View on GitHub (pinned to b379c1b69e)
When it happens
Trigger: Thrown at lib/matplotlib/dviread.py:1248 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of matplotlib/matplotlib@b379c1b69e (2026-08-21).
Data as JSON: /api/errors/395e6674a5aa0778.
Report an issue: GitHub.