diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index c246bf978c1f..60a47dc6126b 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -6,6 +6,7 @@ import math import os import sys +import errno import re import shutil import tempfile @@ -316,8 +317,14 @@ def __init__(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=self.tmpdir) - except OSError: - raise RuntimeError("Error starting process '%s'" % self.texcommand) + except OSError as e: + if e.errno == errno.ENOENT: + raise RuntimeError("Latex command not found. " + "Install '%s' or change pgf.texsystem to the desired command." + % self.texcommand + ) + else: + raise RuntimeError("Error starting process '%s'" % self.texcommand) test_input = self.latex_header + latex_end stdout, stderr = latex.communicate(test_input.encode("utf-8")) if latex.returncode != 0: