FileNotFound Error arose while I was executing subprocess.run() through the code below in Python:
from subprocess import run, DEVNULL, PIPE
def Befehl_Schreiber():
flag_op = 'DEVNULL'
flag_err = 'PIPE'
befehl = 'usearch11 -threads 8 -fastq_filter ' + '.\Rohrdaten\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001.fastq' + ' -fastq_maxee 1 -fastq_minlen 120 -fastq_maxns 0 -fastaout ' + '.\\1_QC\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001--1.QC.fasta'
return "'" + befehl + "'" + ', stdout=' + flag_op + ', stderr=' + flag_err + ', shell = True' + ', text = True'
command = Befehl_Schreiber()
print(command)
process = run(command)
the outcome as well as errors from code above in cmd is as below:
'usearch11 -threads 8 -fastq_filter .\Rohrdaten\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001.fastq -fastq_maxee 1 -fastq_minlen 120 -fastq_maxns 0 -fastaout .\1_QC\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001--1.QC.fasta', stdout=DEVNULL, stderr=PIPE, shell = True, text = True
Traceback (most recent call last):
File "Fragestellung.py", line 13, in <module>
process = run(command)
File "C:\Program Files\Python38\lib\subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Program Files\Python38\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python38\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
when I copy the first line of the output above which is result of print(command) function in first code block into the place where 'command' was, the script is again running without problem:
from subprocess import run, DEVNULL, PIPE
def Befehl_Schreiber():
flag_op = 'DEVNULL'
flag_err = 'PIPE'
befehl = 'usearch11 -threads 8 -fastq_filter ' + '.\Rohrdaten\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001.fastq' + ' -fastq_maxee 1 -fastq_minlen 120 -fastq_maxns 0 -fastaout ' + '.\\1_QC\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001--1.QC.fasta'
return "'" + befehl + "'" + ', stdout=' + flag_op + ', stderr=' + flag_err + ', shell = True' + ', text = True'
process = run('usearch11 -threads 8 -fastq_filter .\Rohrdaten\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001.fastq -fastq_maxee 1 -fastq_minlen 120 -fastq_maxns 0 -fastaout .\1_QC\pmFLP135_143_148_KWB3_1_1_5_S1_L001_R1_001--1.QC.fasta', stdout=DEVNULL, stderr=PIPE, shell = True, text = True)
I could not figure out where the problem lies in...any help will be appreciated.