2017-12-20 2 views
0

Ich versuche, diesen Befehl über Python-Subprozess auszuführen. Mein aktuelles Verzeichnis enthält den Ordner splitta103, der sowohl die Datei sbd.py als auch den Ordner model_nb enthält.OSError: [Errno 2] Keine solche Datei oder kein Verzeichnis. Dateien, die bereits im aktuellen Verzeichnis vorhanden sind

Python splitta103/sbd.py -m splitta103/model_nb info.txt

Das ist mein Python-Programm

file = 'info.txt' 

print(subprocess.check_output(['splitta103','/','sbd.py','-m','splitta103','/','model_nb',file])) 

Hier wird der Fehler

--------------------------------------------------------------------------- 
OSError         Traceback (most recent call last) 
<ipython-input-27-743654b05145> in <module>() 
    12 text_file = 'info.txt' 
    13 
---> 14 print(subprocess.check_output(['splitta103','/','sbd.py','-m','splitta103','/','model_nb','info.txt'])) 
    15 #print(subprocess.check_output(['sbd.py','-m','model_nb','info.txt'])) 
    16 

/home/joe/anaconda2/lib/python2.7/subprocess.pyc in check_output(*popenargs, **kwargs) 
    210  if 'stdout' in kwargs: 
    211   raise ValueError('stdout argument not allowed, it will be overridden.') 
--> 212  process = Popen(stdout=PIPE, *popenargs, **kwargs) 
    213  output, unused_err = process.communicate() 
    214  retcode = process.poll() 

/home/joe/anaconda2/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags) 
    388         p2cread, p2cwrite, 
    389         c2pread, c2pwrite, 
--> 390         errread, errwrite) 
    391   except Exception: 
    392    # Preserve original exception in case os.close raises. 

/home/joe/anaconda2/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) 
    1023       raise 
    1024     child_exception = pickle.loads(data) 
-> 1025     raise child_exception 
    1026 
    1027 

OSError: [Errno 2] No such file or directory 

Antwort

1

Dieses: print(subprocess.check_output(['splitta103','/','sbd.py','-m','splitta103','/','model_nb','info.txt']))

würde aussehen wie: splitta103/sbd.py -m splitta103/model_nb info.txt in der Befehlszeile.

Dieses auf der Kommandozeile: python splitta103/sbd.py -m splitta103/model_nb info.txt

mit dieser hergestellt werden: ['python', 'splitta103/sbd.py', '-m', 'splitta103/model_nb', 'info.txt']

+0

Danke, seine Arbeiten. habe meinen Fehler verstanden. – joel

Verwandte Themen