1. 程式人生 > >psutil.Popen執行python命令,提示/bin/sh: locust: not found

psutil.Popen執行python命令,提示/bin/sh: locust: not found

原來:

cmd = 'locust -f %s --slave --no-reset-stats --master-host=%s' % (script_file[i], master_host)
psutil.Popen(cmd, shell=True, stdout=None, stderr=None)

將命令改為:

psutil.Popen(cmd, shell=True, stdout=None, stderr=None, executable="/usr/bin/python")