1

Code [deprecated; see revision 2] which I run with XeLaTeX--shell-escape in TextMate of OS X 10.11.4 El Capitan

\documentclass{article}
\usepackage{graphicx}
\usepackage{python} % http://tex.stackexchange.com/a/53465/13173
%% OS X http://tex.stackexchange.com/a/136318/13173
% XeLaTeX--shell-escape

\begin{document}

\begin{python}
import os
directory = "/Users/masi/Desktop/testEps/eps"
extension = ".eps"
files = [file for file in os.listdir(directory) if file.lower().endswith(extension)]

for file in files:
   if 
   print r"\begin{figure}"
   print r"\includegraphics[scale=0.3]{%s}" % file
   print r"\caption{File %s}" % file
   print r"\label{Serie%s}" % file
   print r"\end{figure}"
\end{python}

\end{document}

Expected out is some pictures. I see in logs that figures are correctly loaded. However, the output is a blank document with a pagenumber without pictures.

Revision 2 after egrep

\documentclass{article}
\usepackage{graphicx}
\usepackage{python} % http://tex.stackexchange.com/a/53465/13173
%% OS X http://tex.stackexchange.com/a/136318/13173
% XeLaTeX--shell-escape

\graphicspath{{/Users/masi/Desktop/testEps/eps}}

\begin{document}

\begin{python}
import os
directory = "/Users/masi/Desktop/testEps/eps"
extension = ".eps"
files = [file for file in os.listdir(directory) if file.lower().endswith(extension)]

for file in files:
   print r"\begin{figure}"
   print r"\includegraphics[scale=0.3]{%s}" % file
   print r"\caption{File %s}" % file
   print r"\label{Serie%s}" % file
   print r"\end{figure}"
\end{python}

\end{document}

but still same output. Content in .py.out

\begin{figure}
\includegraphics[scale=0.3]{test.eps}
\caption{File test.eps}
\label{Serietest.eps}
\end{figure}
\begin{figure}
\includegraphics[scale=0.3]{test2.eps}
\caption{File test2.eps}
\label{Serietest2.eps}
\end{figure}

which is correct. In logs after runsystem

(./test.py.out
^^JLaTeX Warning: File `test.eps' not found on input line 2.^^J
./test.py.out:2: Unable to load picture or PDF file 'test.eps'.
<to be read again> 
                   }
l.2 ...cale=0.3]{test.eps}

The requested image couldn't be read because
it was not a recognized image format.

This is strange because I could load the .eps image individually in the document before setting up Python in the processing. However, removing option --shel-escape does not lead to expected output anymore.

Test without Python

Code

\documentclass{article}
\usepackage{graphicx}
\graphicspath{{/Users/masi/Desktop/testEps/eps/}}
\begin{document}
\begin{figure}
\includegraphics[scale=0.3]{test.eps}
\end{figure}
\end{document}

Errors

Document Class: article 2014/09/29 v1.4h Standard LaTeX document class

Latex Error: ./test.tex:6 Unable to load picture or PDF file '/Users/masi/Desktop/testEps/eps/test.eps'.

Including: "/Users/masi/Desktop/testEps/eps/test.eps"
Latex Error: ./test.tex:6 Unable to load picture or PDF file '/Users/masi/Desktop/testEps/eps/test.eps'.

Latex Error: ./test.tex:8 Output loop---100 consecutive dead cycles.

This is a strange behaviour where the removal of Python did not help. Either Python strange something in the system or I have some bug, which I have not noticed. I do not understand the error 100 consecutive dead cycles.


Why is there no output of figures in the case?

1 Answers1

2

You have a stray if in the Python code. You're also missing \graphicspath.

In the code below I masked off the real path I used.

\documentclass{article}
\usepackage{graphicx}
\usepackage{python} % http://tex.stackexchange.com/a/53465/13173
%% OS X http://tex.stackexchange.com/a/136318/13173
% XeLaTeX--shell-escape

\graphicspath{{<maskedInformation>/testeps/}}

\begin{document}

\begin{python}
import os
directory = "<maskedInformation>/testeps/"
extension = ".eps"
files = [file for file in os.listdir(directory) if file.lower().endswith(extension)]

for file in files:
   print r"\begin{figure}"
   print r"\includegraphics[scale=0.3]{%s}" % file
   print r"\caption{File %s}" % file
   print r"\label{Serie%s}" % file
   print r"\end{figure}"
\end{python}

\end{document}
egreg
  • 1,121,712