小编Nii*_*itz的帖子

subprocess.call在Windows上使用cygwin而不是cmd

我在Windows 7上进行编程,在我的一个Python项目中,我需要调用bedtools,它只适用于Windows上的Cygwin.我是Cygwin的新手,安装了默认版本+ bedtools所需的一切,然后使用Cygwin按照安装说明中的说明使用make安装bedtools .

$ tar -zxvf BEDTools.tar.gz
$ cd BEDTools-<version>
$ make
Run Code Online (Sandbox Code Playgroud)

当我使用Cygwin终端手动调用它时,如下所示,它没有问题,输出文件包含正确的结果.

bedtools_exe_path intersect -a gene_bed_file -b snp_bed_file -wa -wb > output_file
Run Code Online (Sandbox Code Playgroud)

但是当我subprocess.call在我的程序中使用它似乎使用Windows cmd而不是Cygwin时,它不起作用.

arguments = [bedtools_exe_path, 'intersect', '-a', gene_bed_file, '-b',
             snp_bed_file, '-wa', '-wb', '>', output_file]
return_code = suprocess.call(arguments)
Run Code Online (Sandbox Code Playgroud)

结果没有输出文件和返回码3221225781.


arguments = [bedtools_exe_path, 'intersect', '-a', gene_bed_file, '-b',
             snp_bed_file, '-wa', '-wb', '>', output_file]
return_code = suprocess.call(arguments, shell=True)
Run Code Online (Sandbox Code Playgroud)

导致空输出文件和返回码的结果3221225781.


cygwin_bash_path = 'D:/Cygwin/bin/bash.exe'
arguments = [cygwin_bash_path, bedtools_exe_path, 'intersect', '-a', …
Run Code Online (Sandbox Code Playgroud)

python windows cygwin subprocess cmd

6
推荐指数
1
解决办法
4147
查看次数

标签 统计

cmd ×1

cygwin ×1

python ×1

subprocess ×1

windows ×1