1

I'm a Windows user and I use MiKTeX and TeXstudio. Not long ago I tried to use gnuplottex. In the process I ran into problems and gave up and did not understand the essence of. Yesterday i tried to compile example of python package and got error

I can't find file `pytex.py.out'.

Here is example:

\documentclass{article}
\usepackage{python}
\begin{document}
\section*{Hello, Python-inside-\LaTeX!}
\begin{python}
print r'\begin{verbatim}
import this
print r'\end{verbatim}
\end{python}
\end{document}

At the moment I realized that every thing, which need --shell-escape does not work. Through this advice I checked that --shell-escape is enabled. Summing up all this information: I totally don't understand what is wrong with this.

1

It looks like a syntax error. Try this:

\documentclass{article}
\usepackage{python}

\begin{document}
\section*{Hello, Python-inside-\LaTeX!}
\begin{python}[Code.py]
    print("Hello again.")
\end{python}
\end{document}

Where Code.py contains:

# Test python code
print "Hello World!"

And run with (or equivalent):

pdflatex -shell-escape FileName.tex

This should first insert the python code from Code.py and then the code between the begin and end statements.

  • i got the same with this – JHZTME UIBNA Sep 3 '16 at 18:51
0

pytex.py.out is not being generated because your Python code is generating an error due to the unclosed single quotes in the begin/end verbatim lines.

Here's a corrected version:

\documentclass{article}
\usepackage{python}
\begin{document}
\section*{Hello, Python-inside-\LaTeX!}
\begin{python}
print r'\begin{verbatim}'
import this
print r'\end{verbatim}'
\end{python}
\end{document}

However, if you want to integrate Python into your LaTeX document I recommend the pythontex package, as it's more powerful and flexible than the simple python package.

  • i got the same , when i try to compile it on my computer. But in sharelatex.com it compiled fine. Any ideas? – JHZTME UIBNA Sep 3 '16 at 18:58
  • Is Python installed on your computer and in your PATH? Is a pytex.py.err file being generated in the directory where you're compiling your latex file? – Paul M. Sep 3 '16 at 19:06
  • Damn.Now i did it,i downloaded python 3.5.2 and choosed in the installer add Python in PATH. That's it? – JHZTME UIBNA Sep 3 '16 at 19:25
  • Probably. As long as latex (via --shell-escape) can find the Python executable. Though that may depend on your OS, latex setting, etc. – Paul M. Sep 3 '16 at 19:43
  • Apparently,latex did not find Python.I got a feeling that in my case latex with shell work wrong and cant find things.Can i link it manually? – JHZTME UIBNA Sep 3 '16 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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