Sublime Forum

OS X FileNotFoundError

#1

I had written a plugin to open corresponding pdf files for LaTeX source files, it works on windows, however, after going to OS X (and changed the path to the pdf previewer), I got the following error:

File "./subprocess.py", line 1448, in _execute_child FileNotFoundError: [Errno 2] No such file or directory: 'open -a /Applications/Skim.app /working/foo.pdf'

Running open -a /Applications/Skim.app /working/foo.pdf from the terminal.app works fine, but not in sublime text 3. How can I fix this?

import sublime, sublime_plugin,os,subprocess

class pdfopener(sublime_plugin.EventListener):
	def on_load(self, view):
		fs=view.file_name()
		fsp=fs:-4]+".pdf"
		print(fsp)

		if fs-4:]=='.tex' and os.path.isfile(fsp):
			subprocess.Popen("open -a /Applications/Skim.app "+fsp)
0 Likes

#2

It is recommended to use a list or tuple for args in Popen. Something like:

subprocess.Popen(("open", "-a", "/Applications/Skim.app", fsp))
0 Likes