Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Remove the comment character % after \begin{python} –  egreg Jun 30 '13 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 '13 at 13:01

1 Answer 1

up vote 16 down vote accepted

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.

share|improve this answer
    
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 '13 at 19:52
    
@jafan Sorry, but I don't know what to say, apart from “install Linux”. ;-) –  egreg Jul 1 '13 at 20:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.