![](/img/trans.png)
[英]Subprocess command shows FileNotFoundError: [Errno 2] No such file or directory
[英]Asyncio create_subprocess_exec FileNotFoundError: [Errno 2] No such file or directory:
我正在嘗試創建一個異步管道,該管道可用於與我創建的子進程交互。 我在嘗試創建進程時遇到了找不到文件錯誤的問題。 正如您在下面的代碼中看到的那樣,我能夠以同步方式使用常規Popen
創建子流程。 誰能幫我克服這個錯誤?
代碼:
# I've created the command and args string/dictionary above. They are all valid.
# I can run the command from the command line and it works
import pprint
pp = pprint.PrettyPrinter().pprint
pp(popen_params)
print(" ".join(cmd))
sp.Popen(cmd, **popen_params)
print("Made it past initially creating the pipe")
self.async_proc = self.loop.run_until_complete(asyncio.create_subprocess_exec(" ".join(cmd), **popen_params))
輸出:
{'bufsize': 0, 'stderr': -1, 'stdin': -3, 'stdout': -1}
/usr/local/bin/ffmpeg -i /Users/OWNER/Google Drive/yolo.mp4 -loglevel error -f image2pipe -vf scale=1280:720 -sws_flags bicubic -pix_fmt rgb24 -vcodec rawvideo -
Made it past initially creating the pipe
Traceback (most recent call last):
File "movie_trial.py", line 97, in <module>
clip = VideoFileClip("/Users/OWNER/Google Drive/yolo.mp4")
File "/Users/OWNER/Documents/Projects/moivepy_vendoring/moviepy/video/io/VideoFileClip.py", line 94, in __init__
loop=self.loop)
File "/Users/OWNER/Documents/Projects/moivepy_vendoring/moviepy/video/io/ffmpeg_reader.py", line 72, in __init__
self.async_initialize()
File "/Users/OWNER/Documents/Projects/moivepy_vendoring/moviepy/video/io/ffmpeg_reader.py", line 119, in async_initialize
self.async_proc = self.loop.run_until_complete(asyncio.create_subprocess_exec(" ".join(cmd), **popen_params))
File "/anaconda3/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/anaconda3/lib/python3.6/asyncio/subprocess.py", line 225, in create_subprocess_exec
stderr=stderr, **kwds)
File "/anaconda3/lib/python3.6/asyncio/base_events.py", line 1211, in subprocess_exec
bufsize, **kwargs)
File "/anaconda3/lib/python3.6/asyncio/unix_events.py", line 200, in _make_subprocess_transport
**kwargs)
File "/anaconda3/lib/python3.6/asyncio/base_subprocess.py", line 39, in __init__
stderr=stderr, bufsize=bufsize, **kwargs)
File "/anaconda3/lib/python3.6/asyncio/unix_events.py", line 706, in _start
universal_newlines=False, bufsize=bufsize, **kwargs)
File "/anaconda3/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/anaconda3/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/ffmpeg -i /Users/OWNER/Google Drive/yolo.mp4 -loglevel error -f image2pipe -vf scale=1280:720 -sws_flags bicubic -pix_fmt rgb24 -vcodec rawvideo -': '/usr/local/bin/ffmpeg -i /Users/OWNER/Google Drive/yolo.mp4 -loglevel error -f image2pipe -vf scale=1280:720 -sws_flags bicubic -pix_fmt rgb24 -vcodec rawvideo -'
您將以下內容作為單個命令調用
/usr/local/bin/ffmpeg -i /Users/OWNER/Google Drive/yolo.mp4 -loglevel error -f image2pipe -vf scale=1280:720 -sws_flags bicubic -pix_fmt rgb24 -vcodec rawvideo -': '/usr/local/bin/ffmpeg -i /Users/OWNER/Google Drive/yolo.mp4 -loglevel error -f image2pipe -vf scale=1280:720 -sws_flags bicubic -pix_fmt rgb24 -vcodec rawvideo -
僅在第一個參數中使用命令,然后在第二個參數中將任何額外參數作為列表傳遞。 請參閱此鏈接: https : //docs.python.org/3/library/subprocess.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.