{"record":{"id":"d44e7d6a009b418c","repo":"matplotlib/matplotlib","slug":"mpl-rcparams-pgf-texsystem-r-not-found-insta","errorCode":null,"errorMessage":"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change rcParams['pgf.texsystem'] to an available TeX implementation","messagePattern":"(.+?) not found; install it or change rcParams\\['pgf\\.texsystem'\\] to an available TeX implementation","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/backends/backend_pgf.py","lineNumber":298,"sourceCode":"                f\"{self._build_latex_header()}\",\n                stdout)\n        self.latex = None  # Will be set up on first use.\n        # Per-instance cache.\n        self._get_box_metrics = functools.lru_cache(self._get_box_metrics)\n\n    def _setup_latex_process(self, *, expect_reply=True):\n        # Open LaTeX process for real work; register it for deletion.  On\n        # Windows, we must ensure that the subprocess has quit before being\n        # able to delete the tmpdir in which it runs; in order to do so, we\n        # must first `kill()` it, and then `communicate()` with or `wait()` on\n        # it.\n        try:\n            self.latex = subprocess.Popen(\n                [mpl.rcParams[\"pgf.texsystem\"], \"-halt-on-error\", \"-no-shell-escape\"],\n                stdin=subprocess.PIPE, stdout=subprocess.PIPE,\n                encoding=\"utf-8\", cwd=self.tmpdir)\n        except FileNotFoundError as err:\n            raise RuntimeError(\n                f\"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change \"\n                f\"rcParams['pgf.texsystem'] to an available TeX implementation\"\n            ) from err\n        except OSError as err:\n            raise RuntimeError(\n                f\"Error starting {mpl.rcParams['pgf.texsystem']!r}\") from err\n\n        def finalize_latex(latex):\n            latex.kill()\n            try:\n                latex.communicate()\n            except RuntimeError:\n                latex.wait()\n\n        self._finalize_latex = weakref.finalize(\n            self, finalize_latex, self.latex)\n        # write header with 'pgf_backend_query_start' token\n        self._stdin_writeln(self._build_latex_header())","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/backends/backend_pgf.py#L280-L316","documentation":"backend_pgf spawns rcParams['pgf.texsystem'] (an engine such as xelatex, pdflatex or lualatex) as a subprocess. A FileNotFoundError from Popen — the configured engine is not on PATH — is re-raised as a RuntimeError that tells you to install the engine or point pgf.texsystem at one that exists.","triggerScenarios":"Using the pgf backend on a machine with no TeX distribution installed, or with pgf.texsystem set to an engine variant that is absent (e.g. 'lualatex' missing while only pdflatex is installed).","commonSituations":"Slim Docker images, fresh OS installs, Windows with MiKTeX not on PATH, conda environments without a tex package, CI runners lacking latex.","solutions":["Install a TeX distribution (TeX Live, MiKTeX) and make sure its bin directory is on PATH","Point rcParams['pgf.texsystem'] at an engine you actually have: mpl.rcParams['pgf.texsystem'] = 'pdflatex'","Verify visibility first: shutil.which(mpl.rcParams['pgf.texsystem'])","If TeX is unavailable, use a non-TeX backend (Agg/PDF/SVG)"],"exampleFix":"# before\nmpl.rcParams['pgf.texsystem'] = 'xelatex'  # xelatex not installed -> RuntimeError\nmpl.use('pgf')\n\n# after\nmpl.rcParams['pgf.texsystem'] = 'pdflatex'  # engine that IS on PATH\nmpl.use('pgf')","handlingStrategy":"validation","validationCode":"import shutil\nimport matplotlib as mpl\n\ndef texsystem_available() -> bool:\n    return shutil.which(mpl.rcParams['pgf.texsystem']) is not None\n\nif not texsystem_available():\n    for engine in ('pdflatex', 'xelatex', 'lualatex'):\n        if shutil.which(engine):\n            mpl.rcParams['pgf.texsystem'] = engine\n            break\n    else:\n        raise SystemExit('no TeX engine found; install TeX Live or MiKTeX')","typeGuard":null,"tryCatchPattern":"try:\n    mpl.use('pgf')\n    fig.savefig('out.pgf')\nexcept RuntimeError as err:\n    if 'not found' not in str(err):\n        raise\n    mpl.rcParams['pgf.texsystem'] = 'pdflatex'  # an engine that exists\n    fig.savefig('out.pgf')","preventionTips":["Check shutil.which(mpl.rcParams['pgf.texsystem']) before selecting the pgf backend","Install a TeX distribution and verify with 'pdflatex --version' on PATH","In containers, install texlive explicitly rather than assuming it"],"tags":["matplotlib","pgf","latex","tex-distribution","path","executable"],"backgroundTag":"executable-not-found","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}