I am a beginner in Latex/Python and try to run the file below on my Mac (10.8.4 – latest MacTex). This is just a test file and it is not running. Python is running in the console and I have copied python.sty into the folder "library/texmf".
Can you tell me what the problem might be? Would be really helpful. I couldnt find any solution on the internet. Thanks in advance!!!
Andreas
CODE
%& -shell-escape
\documentclass{article}
\usepackage{python}
\begin{document}
Say hello Python:
\begin{python}%
print "hi"
\end{python}%
\end{document}
Message from Latex
This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
(./Ohne-Titel.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2013/texmf-dist/tex/latex/python/python.sty)
(./Ohne-Titel.aux)
! I can't find file `Ohne-Titel.py.out'.
<to be read again>
\def
l.10 \end{python}
%
(Press Enter to retry, or Control-D to exit)
Please type another input file name:
Best Answer
The
%& -shell-escape
first line is not sufficient to enable shell escape with TeX Live (MacTeX). This is confirmed by your log: you havewhile it should be
with shell escape enabled.
Here's how you can do with TeXworks.
Open the Preferences panel in TeXworks and go to the Typesetting tab
Click on the “+” button in the lower part
Now fill in the “Tool configuration” window as shown below
For adding a line in the “Arguments” section, click on the “+” button (three times, in this case).
Use the following first line in your document
so that the typesetting tool will be the one just created.
The complete file will then be
Here's the result after hitting the “compile” button:
You might add the
--shell-escape
argument to the standard XeLaTeX tool, but it's better not doing it, as shell escape should be enabled with caution only for “safe” file (your files or those coming from a trusted source).