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 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}
share|improve this question
add comment

migrated from stackoverflow.com Apr 30 '12 at 16:07

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

3 Answers

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
Your package looks very promising, I will definitely try it out soon! –  Alexander May 1 '12 at 15:33
add comment

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.