[Tex/LaTex] Can’t make Python package work

python

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.

Best Answer

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.