[Tutor] No file or directory error using subprocess and Popen
boB Stepp
robertvstepp at gmail.com
Mon May 15 00:19:12 EDT 2017
On Sun, May 14, 2017 at 10:57 PM, Jim <jf_byrnes at comcast.net> wrote:
> I am running this on Mint 18.
> This is the third script I have written to open and position windows in
> workspaces. The first two work, but trying to open ebook-viewe r (calibre)
> with a specific book produces the following error.
> If I run the same command in the terminal it works without an error.
>
>
> Exception in thread Thread-4:
> Traceback (most recent call last):
> File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
> self.run()
> File "/usr/lib/python3.5/threading.py", line 862, in run
> self._target(*self._args, **self._kwargs)
> File "/home/jfb/MyProgs/Scripts/place_windows_OO_WS3.py", line 24, in
> open_it
> subprocess.call([self.program])
> File "/usr/lib/python3.5/subprocess.py", line 557, in call
> with Popen(*popenargs, **kwargs) as p:
> File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
> restore_signals, start_new_session)
> File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
> raise child_exception_type(errno_num, err_msg)
> FileNotFoundError: [Errno 2] No such file or directory: 'ebook-viewer
> /home/jfb/Documents/eBooks/Javascript/GOOGLE_SHEETS/googlespreadsheetprogramming.epub'
>
> Code:
>
> # place_windows_OO_WS3.py
>
> import subprocess
> from subprocess import Popen,PIPE
> import threading
> import time
>
> class Place():
>
> def __init__(self):
> self.programs = ['jedit', 'google-chrome', 'doublecmd',
> 'ebook-viewer
> /home/jfb/Documents/eBooks/Javascript/GOOGLE_SHEETS/googlespreadsheetprogramming.epub']
> self.classname = {'jedit' : 'sun-awt-X11-XFramePeer',
> 'google-chrome':'google-chrome',
> 'doublecmd':'doublecmd',
> 'calibre-ebook-viewer': 'libprs500'}
> self.open_and_move()
>
> def open_it(self):
> subprocess.call([self.program])
I'm not very familiar with using the subprocess module yet, but when
the above call to "subprocess.call([self.program])" occurs, isn't
subprocess.call() expecting a list like
['ebook-viewer', '/home/jfb ...']
?
Hope I am not off-track here.
boB
More information about the Tutor
mailing list