Home Download Buy Blog Forum Support

[BUG] Launching external commands with Popen

Re: [BUG] Launching external commands with Popen

Postby jps on Mon Oct 31, 2011 10:13 pm

It's almost certainly a path issue. Rather than setting $PATH, try providing a full path to the executables and see if that helps.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: [BUG] Launching external commands with Popen

Postby Marciano on Tue Nov 01, 2011 2:32 am

So I added the full path to the "cmd" option in LaTeX.sublime-build, and also to the "-e", "$pdflatex = ..." line (which gets passed to latexmk). Nothing seems to work... I am really at my wits' ends on this one :-(
Marciano
 
Posts: 146
Joined: Fri Sep 18, 2009 2:55 am

Re: [BUG] Launching external commands with Popen

Postby jps on Tue Nov 01, 2011 3:24 am

Hrm... explicit paths won't help, as the issue is presumably that when epstopdf is launched, it's expected to be in the path, which is likely isn't. Sublime Text itself doesn't do anything with Popen, there should be no difference between calling Popen within Sublime Text or within Python, except for the difference in $PATH.

Take a look at http://stackoverflow.com/questions/5658 ... nment-path, I believe the answer given there (either set the path with env=... and use shell=True, or run the process via /usr/bin/env) should solve this issue.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: [BUG] Launching external commands with Popen

Postby Marciano on Wed Nov 02, 2011 7:48 pm

Grr... so I tried adding

env = {"PATH": <path>}

to the subprocess.Popen call: no dice. I added /usr/bin/env, i.e. doing

subprocess.Popen(['/usr/bin/env'] + cmd)

where cmd is the list containing the latexmk command: nothing. I added shell=True, and here what happens is, mysteriously, latexmk produces a dvi file instead of a pdf file.

I am not sure that the path is the problem. When I run the python script in the first post of this thread, everything works just fine, even though I do *not* have tex & friends on my path (i.e. typing "latexmk" at the prompt gives "-bash: command not found".

:-(
Marciano
 
Posts: 146
Joined: Fri Sep 18, 2009 2:55 am

Re: [BUG] Launching external commands with Popen

Postby jps on Thu Nov 03, 2011 9:48 am

Following along with sublimator's suggestion, try launching Sublime Text from the terminal, rather than from finder, e.g.,

- Quit Sublime Text 2
- run "/Applications/Sublime Text 2.app/Contents/MacOS/sublime_text" from the terminal
- check on.environ in the console to verify that it's different from os.environ when launched from Finder

It'd be interesting to see if that helps the issue.

(I realise I'm just parroting the above message, but it's not always obvious how to launch an application from the terminal in OS X)
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: [BUG] Launching external commands with Popen

Postby Marciano on Thu Nov 03, 2011 2:47 pm

THANKS!!!

I think I solved the mystery. Launching ST2 from the console works. /usr/texbin is NOT on the path, but that's NOT what's causing users problems. The epstopdf command invokes ghostscript, which (on OSX) is in /usr/local/bin. So, adding /usr/local/bin to the "path" variable in LaTeX.sublime-build fixes the issue.

Thanks!!!
Marciano
 
Posts: 146
Joined: Fri Sep 18, 2009 2:55 am

Re: [BUG] Launching external commands with Popen

Postby Marciano on Thu Nov 03, 2011 9:24 pm

I assume you have already looked at the Console (for logs) and the Activity Monitor (for processes)?
Marciano
 
Posts: 146
Joined: Fri Sep 18, 2009 2:55 am

Previous

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 19 guests