我有一个 python GUI,我想运行一个 shell 命令,但使用 Windows cmd 无法执行该命令 我已经安装了 cygwin,我想知道如何运行 cygwin 而不是 Windows cmd。我想使用子进程并获取 .sh 文件的结果 但我的代码
subprocess.check_output("./listChains.sh < 2p31protein.pdb")
这将在 cmd 中运行它,因为 windows 无法识别它,所以它不起作用,所以我怎样才能让它在 cygwin 而不是 cmd 中运行
最佳答案
执行 cygwin shell(例如 bash
)并让它运行您的脚本,而不是直接运行您的脚本:
subprocess.check_output("C:/cygwin/bin/bash.exe ./listChains.sh < 2p31protein.pdb")
或者,关联 .sh
文件类型扩展名以使用 bash.exe
打开。
关于python - cygwin 运行命令而不是 cmd python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13529852/