14

I found example of the using Python in LaTex, but unfortunately I have problem with it.

  • Microsoft Windows [Version 6.2.9200]
  • This is XeTeX, Version 3.1415926-2.5-0.9999.3 (MiKTeX 2.9 32 bit)
  • Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AM D64)] on win32

MNWE: (xetex --enable-write18 hello.tex)

\documentclass{article}
\usepackage{python}
\begin{document}

Say hello Python:

\begin{python}%
print r"Hello \LaTeX!"
\end{python}%
\end{document}

Latex Error: I can't find hello.py.out!

But two files (hello.py, latex.py) was generated. Could anyone help me?

2
  • Remove the comment character % after \begin{python}
    – egreg
    Commented Jun 30, 2013 at 20:49
  • 1
    The original python.sty doesn't work with Windows. You might try a modified version (such as this). Or if you want the additional features, you might consider pythontex.
    – G. Poore
    Commented Jul 2, 2013 at 13:01

1 Answer 1

18

The code compiles fine if I remove the % characters:

\documentclass{article}
\usepackage{python}
\begin{document}

Say hello Python:

\begin{python}
print r"Hello \LaTeX!"
\end{python}

\end{document}

The problem is that \begin{python} needs to see an end-of-line to start it working; and if you comment it, the next one that's seen is too late and the print line is gobbled, so nothing is written out.

2
  • I still have same problem. Removing % characters haven't any effect. (error: I can't find hello.py.out!). It makes me sad.
    – JardaFait
    Commented Jul 1, 2013 at 19:52
  • @jafan Sorry, but I don't know what to say, apart from “install Linux”. ;-)
    – egreg
    Commented Jul 1, 2013 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .