From dd150e7006dd3f363c4ab686b40530fcf15943b0 2015-01-14 20:11:32 From: Min RK Date: 2015-01-14 20:11:32 Subject: [PATCH] Merge pull request #7453 from takluyver/check-latex-commands Check for latex commands to improve error messages when commands are missing --- diff --git a/IPython/nbconvert/exporters/pdf.py b/IPython/nbconvert/exporters/pdf.py index d79610b..dd4d548 100644 --- a/IPython/nbconvert/exporters/pdf.py +++ b/IPython/nbconvert/exporters/pdf.py @@ -7,6 +7,7 @@ import subprocess import os import sys +from IPython.utils.process import find_cmd from IPython.utils.traitlets import Integer, List, Bool, Instance from IPython.utils.tempdir import TemporaryWorkingDirectory from .latex import LatexExporter @@ -57,13 +58,18 @@ class PDFExporter(LatexExporter): or failed (False). """ command = [c.format(filename=filename) for c in command_list] - #In windows and python 2.x there is a bug in subprocess.Popen and + + # On windows with python 2.x there is a bug in subprocess.Popen and # unicode commands are not supported if sys.platform == 'win32' and sys.version_info < (3,0): #We must use cp1252 encoding for calling subprocess.Popen #Note that sys.stdin.encoding and encoding.DEFAULT_ENCODING # could be different (cp437 in case of dos console) command = [c.encode('cp1252') for c in command] + + # This will throw a clearer error if the command is not found + find_cmd(command_list[0]) + times = 'time' if count == 1 else 'times' self.log.info("Running %s %i %s: %s", command_list[0], count, times, command) with open(os.devnull, 'rb') as null: