在使用Python的subprocess模块执行命令和参数时,出现了"OSError: [Errno 2] No such file or directory"的错误。

21 浏览
0 Comments

在使用Python的subprocess模块执行命令和参数时,出现了"OSError: [Errno 2] No such file or directory"的错误。

我正在尝试在Python代码中使用subprocess.call()运行程序进行一些系统调用,但是出现以下错误:

Traceback (most recent call last):

File "", line 1, in

File "/usr/lib/python2.7/subprocess.py", line 493, in call

return Popen(*popenargs, **kwargs).wait()

File "/usr/lib/python2.7/subprocess.py", line 679, in __init__

errread, errwrite)

File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child

raise child_exception

OSError: [Errno 2] No such file or directory

我的实际Python代码如下:

url = "/media/videos/3cf02324-43e5-4996-bbdf-6377df448ae4.mp4"
real_path = "/home/chanceapp/webapps/chanceapp/chanceapp"+url
fake_crop_path = "/home/chanceapp/webapps/chanceapp/chanceapp/fake1"+url
fake_rotate_path = "/home/chanceapp/webapps/chanceapp.chanceapp/fake2"+url
crop = "ffmpeg -i %s -vf "%(real_path)+"crop=400:400:0:0 "+ "-strict -2 %s"%(fake_crop_path)
rotate = "ffmpeg -i %s -vf "%(fake_crop_path)+"transpose=1 "+"%s"%(fake_rotate_path)
move_rotated = "mv"+" %s"%(fake_rotate_path)+" %s"%(real_path)
delete_cropped = "rm "+"%s"%(fake_crop_path)
#系统调用:
subprocess.call(crop)

我能得到一些相关的解决办法吗?

0