SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 365 forks source link

Using tex-option=-shell-escape different behaviour from command line and from Sublime Text on Windows with LaTeX python-package #440

Open saikon opened 10 years ago

saikon commented 10 years ago

I am trying to get Python-scripts to run from inside my LaTeX documents. I am using Windows and MikTeX with texify.

I modified the traditionalBuilder.py a bit to see which command it executes and to use the same command from the command line manually. I replaced this line:

yield (cmd + [self.tex_name], "Invoking " + cmd[0] + "... ")

With this:

yield (cmd + [self.tex_name], "Invoking " + ' '.join(cmd + [self.tex_name]) + "... ")

The tex-file in question contains this:

\documentclass{article}
\usepackage{python}

\begin{document}

Say hello Python:
\begin{python}%
print(r"Hello \LaTeX!")
\end{python}%

\end{document}

The command used by LaTeXTools to build that file is: texify -b -p --tex-option="--shell-escape" --tex-option="--synctex=1" pythontest2.tex LaTeXTools gives out an error I can't find filepythontest2.py.out'. [\end{python}]`.

The same file compiles just fine when using the same command from command line. It creates the missing pythontest2.py.out file and creates the PDF-just fine.

The -shell-escape option seems to work otherwise fine. Since the below LaTeX-file creates the list.txt just fine when using -shell-escape.

\documentclass{article}
\begin{document}
-shell-escape
\immediate\write18{dir > list.txt}
\end{document}
msiniscalchi commented 10 years ago

Please check the tex log file. There may be additional warnings. I suspect python doesn't get called, most likely due to a path issue. If so, you may try adding your python path to the "texpath" config option.

On Sun, Oct 19, 2014 at 9:28 AM, saikon notifications@github.com wrote:

I am trying to get Python-scripts to run from inside my LaTeX documents. I am using Windows and MikTeX with texify.

I modified the traditionalBuilder.py a bit to see which command it executes and to use the same command from the command line manually. I replaced this line:

yield (cmd + [self.tex_name], "Invoking " + cmd[0] + "... ")

With this:

yield (cmd + [self.tex_name], "Invoking " + ' '.join(cmd + [self.tex_name]) + "... ")

The tex-file in question contains this:

\documentclass{article}\usepackage{python} \begin{document}

Say hello Python:\begin{python}% print(r"Hello \LaTeX!")\end{python}% \end{document}

The command used by LaTeXTools to build that file is: texify -b -p --tex-option="--shell-escape" --tex-option="--synctex=1" pythontest2.tex LaTeXTools gives out an error I can't find file `pythontest2.py.out'. [\end{python}].

The same file compiles just fine when using the same command from command line. It creates the missing pythontest2.py.out file and creates the PDF-just fine.

The -shell-escape option seems to work otherwise fine. Since the below LaTeX-file creates the list.txt just fine when using -shell-escape.

\documentclass{article}\begin{document} -shell-escape\immediate\write18{dir > list.txt}\end{document}

— Reply to this email directly or view it on GitHub https://github.com/SublimeText/LaTeXTools/issues/440.

Marciano Siniscalchi Economics Department, Northwestern University http://faculty.wcas.northwestern.edu/~msi661

saikon commented 10 years ago

Here are the log files: Built from Sublime Text Built from command line

Only difference I can spot is after python gets called (or is tried to get called). Both methods leave the same mark in the log: runsystem(cat pythontest2.py | python > pythontest2.py.out 2> pythontest2.py.err)...executed.

I tested calling python directly using ´´\immediate\write18{python pythonfile.py}``. This executes the python file properly from Sublime Text and from command line.

Adding python path to my texpath did not change things.