Sign up ×
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.

When compiling a .tex file that uses python.sty package and contains:


I keep getting an error:

./main.tex:33:I can't find file 'bin/' \end{python}

./main.tex:33:Emergency stop \end{python}

This happens both when compiling with PDFLaTeX or only LaTeX. What I tried is:

  • ensure -shell-enable is on (or -enable-write18 on Windows),
  • find another copy of python.sty in case my version was invalid,
  • try on Windows 7 and on Debian 6 with Kile
  • copy & paste latex samples using python.sty from the web

None of the above helps in getting rid of that error. It fails even with extremely simple python code within the python environment like: print "a". If also fails when I leave the environment contents empty, but with a different error. It doesn't fail if there are no python environments in the document and there is only \usepackage{python} at the top. My python.sty copy is taken from here. Simple example code I tried to compile is there as well.

What am I missing?

share|improve this question
Where can one obtain a LaTeX package named python? It doesn't seem to be available through the CTAN. – Mico Apr 7 '12 at 13:07
Unfortunately it's not available through CTAN. You can get some backup copies, i.e. It's supposed to be used to embed python code in latex. – rook Apr 7 '12 at 13:20

2 Answers 2

up vote 4 down vote accepted

Below is definition of python environment inspired by python.sty package, but rewritten to work on my Windows system. Basically, it takes content from between \begin{python} and \end{python}, writes it to a file, executes the file as python script and inserts output into the LaTeX document. Full code:






     %Execute python script. Python directory must be in PATH.
     \immediate\write18{python \FNameIn > \FNameOut}

share|improve this answer

It works fine here. Below is the output from the example included in the README file. I did remove the bin/ directory so that I would not need to create that folder. Perhaps you could try that as well. Alternatively, try creating a "bin/" directory where your LaTeX file is. enter image description here

share|improve this answer
Thank you for taking time to investigate it. It didn't fix the issue, though. Did it create a file anywhere for you? – rook Apr 7 '12 at 13:36
I had saved the sample as README.tex (and edited it to remove the non-LaTeX content) and it created various README... files in the same directory where the .tex file was located including If you are on Windows, I know that there are sometimes problems with default path to find Python. Perhaps you can investigate this... I might be able to find some links for you to look at if you don't know what I mean. – André Apr 7 '12 at 13:48
If you mean adding python's directory to PATH environment variable - it's already done. – rook Apr 7 '12 at 13:54
Perhaps try also adding PYTHONPATH as an environment variable ... and perhaps "." as another path variable... – André Apr 7 '12 at 15:27
I'm only wondering what directories should be included in PYTHONPATH then. Location of the .tex file? May I ask what python version and architecture are you running? – rook Apr 7 '12 at 15:55

Your Answer


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.