python在python脚本中运行可执行文件

2024-09-27 22:22:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在python脚本中调用mpi程序,mpi程序是路径“/scratch2/yuhengd/plda+/infer”中的可执行程序

虽然我可以直接从linux命令行运行“infer”(不使用sh或./before the command“/scratch2/yuhengd/plda+/infer”),但我不能使用python脚本中的子进程来调用它,它不会给出任何错误,也不会执行它。python代码如下:

infer_command = "/scratch2/yuhengd/plda+/infer --alpha 0.1 --beta 0.01 --... /scratch2/yuhengd/data/commoncrawl/LDA/local_models/"+forumid+"-commoncrawl-excludeunif-model --total_iterations 500 --burn_in_iterations 250"

print infer_command
exit_status = subprocess.call(infer_command, shell=True)
if exit_status is 1:
    print (forumid + " infer failed")

我该怎么做才能使这项工作成功?谢谢。在

更新: 我使用以下代码测试子进程调用:

导入子流程

^{pr2}$

它不显示任何错误消息,但也没有执行程序。在


Tags: 代码程序脚本进程错误commandprintmpi

热门问题