# Embedding Python in LaTeX - Hello example?

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?

-
Remove the comment character % after \begin{python} –  egreg Jun 30 at 20:49
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 Jul 2 at 13:01

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.

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