OSError: [Errno 2] No such file or directory while using python subprocess in Django

前端 未结 3 1441
不知归路
不知归路 2020-11-28 20:12

I am trying to run a program to make some system calls inside Python code using subprocess.call() which throws the following error:

Traceback (m         


        
3条回答
  •  再見小時候
    2020-11-28 20:30

    Use shell=True if you're passing a string to subprocess.call.

    From docs:

    If passing a single string, either shell must be True or else the string must simply name the program to be executed without specifying any arguments.

    subprocess.call(crop, shell=True)
    

    or:

    import shlex
    subprocess.call(shlex.split(crop))
    

提交回复
热议问题