【发布时间】:2020-06-30 20:40:03
【问题描述】:
有人有在 Python 中使用 subprocess.call 命令的经验吗? 每当我的代码中有这样的行时,我就会不断收到错误:
INFILE1 = open(script_dir+"/Scripts/plot_TSS_profile.R","r")
subprocess.call("Rscript","--slave","--args",filenames["housekeeping_profile"]+" "+filenames["unexpressed_profile"]+" "+filenames["profile_plot"],stdin=INFILE1, stderr=ERR_LOG,stdout=OUT_LOG,shell=True)
INFILE1.close().
如果我保留代码原样,我会收到一个错误,即程序出于某种原因为每个 stdin、stderr 和 stdout 找到多个值,即使这些是代码中唯一的值。如果我取出这些参数并将 infile 放在“--args”之后的括号中,它似乎没有读取文件,因为它说“缓冲区应该是一个整数”。
例如,这种方式给出缓冲区错误:
INFILE1 = script_dir+"/Scripts/plot_TSS_profile.R"
subprocess.call("Rscript",INFILE1,"--slave","--args",filenames["housekeeping_profile"]+" "+filenames["unexpressed_profile"]+" "+filenames["profile_plot"],stderr=ERR_LOG,shell=True)
INFILE1.close()
这里是我的错误输出,以获得更具体的信息:
buffsize上的那个:
Traceback(最近一次调用最后一次): 文件“/mnt/work1/users/pughlab/projects/IEG_MiSEQ/Inferring_DNA_Expression/ExpressionPrediction-master/expression_prediction.py”,第 277 行,在
step5(ERR_LOG,OUT_LOG,args,proj_dir,script_dir,filenames)
File "/mnt/work1/users/pughlab/projects/IEG_MiSEQ/Inferring_DNA_Expression/ExpressionPrediction-master/expression_prediction.py", line 165, in step5
subprocess.call("Rscript",INFILE1,"--slave","--args",filenames["housekeeping_profile"]+" "+filenames["unexpressed_profile"]+" "+filenames["profile_plot"],stderr=ERR_LOG,shell=True)
File "/mnt/work1/software/centos7/python/2.7.15/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/mnt/work1/software/centos7/python/2.7.15/lib/python2.7/subprocess.py", line 343, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
还有一个关于存在多个值的错误:
Traceback (most recent call last):
File "/mnt/work1/users/pughlab/projects/IEG_MiSEQ/Inferring_DNA_Expression/ExpressionPrediction-master/expression_prediction.py", line 272, in <module>
step5(ERR_LOG,OUT_LOG,args,proj_dir,script_dir,filenames)
File "/mnt/work1/users/pughlab/projects/IEG_MiSEQ/Inferring_DNA_Expression/ExpressionPrediction-master/expression_prediction.py", line 165, in step5
subprocess.call("Rscript","--slave","--args",filenames["housekeeping_profile"]+" "+filenames["unexpressed_profile"]+" "+filenames["profile_plot"],stdin=INFILE1,stderr=ERR_LOG,stdout=OUT_LOG,shell=True)
File "/mnt/work1/software/centos7/python/2.7.15/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
TypeError: __init__() got multiple values for keyword argument 'stdin'
谢谢
【问题讨论】:
标签: python python-2.7 subprocess popen