# Error when using the python package

I am very new to LaTeX. I need to run `python` package in LaTeX but I can't. I use MiKTeX 2.9 under Windows 7 but the programs gives me this error:

``````Latex error: ! I can't find file `bin/**filename**.py.out'.

Latex Error: Emergency stop.<read 2> \ end{python}
``````
-

## migrated from stackoverflow.comApr 30 '12 at 16:07

This question came from our site for professional and enthusiast programmers.

Alexander's answer was the one got me going. The python.sty file from python.sty on github worked fine when I changed line 61 from:

``````cat \@pythoninclude\space bin/\jobname.py | python > bin/\jobname.py.out 2> bin/\jobname.py.err
``````

to:

`````` python \jobname.py > \jobname.py.out 2> \jobname.py.err
``````

As you can see I also removed the bin folder. So I also changed line 63 from:

``````\immediate\input bin/\jobname.py.out}
``````

to:

``````\immediate\input \jobname.py.out}
``````

Using this .sty file and adding `-enable-write18` parameter to the command line of `pdflatex` worked for me.

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Martin Schröder May 1 at 9:01

My PythonTeX package is in beta, but it works very well under Windows. It allows fast execution of Python code (only modified code is executed, and code runs in parallel). Python error messages are synchronized with the LaTeX document to give correct line numbers. Also, code can be typeset with built-in access to Pygments.

-
Your package looks very promising, I will definitely try it out soon! –  Alexander May 1 '12 at 15:33

There are several ways to run python through LaTeX. The first `python.sty` file is a bit outdated, I would recommend the updated version from Noon Silk: python.sty on github.

Alternatively there is also SympyTeX, which is written to include the output of the python sympy package into LaTeX documents but works nicely with pure python as well.

Both of these packages are not included on CTAN or MiKTeX.

In both cases LaTeX needs to run your python executable, so it has to be included in the current path. Additionally you have to allow LaTeX to run other executables, e.g. via the `--enable-write18` parameter.

-

At the moment `python.sty` is not in MikTeX package repository. You would have to install it manually.

You can download python.sty from people who have saved the original python.sty by Martin R. Ehmsen. This (bitbucket) is one of such places.

Then copy `python.sty` to your working directory.

This python.sty needs a python interpreter. You need to install one on Windows. Then modify python.sty to call `python.exe` instead of `/usr/bin/python`. I cannot confirm if this would work or not.

This thread on tex.stackexchange.com shows that such modification is possible and provides a version of python.sty modified to work on Windows.

If all goes well you can move it to the local texmf tree as described in MikTeX manual and update path databases.

-
I am sorry but didn't understand what to do with the interpreter. I have already installed python 2.7. Now what do i have to do? –  Jonel_R Apr 30 '12 at 15:01
Open the `python.sty` and make sure that the path to `python.exe` is the correct one. –  Philipp Apr 30 '12 at 16:11
I add the -enable-write28 but it still does not runs. But where it is writen the path to python? Which line? Because I have not found anything yet. –  Jonel_R Apr 30 '12 at 22:46