我在 MacOSX 上使用 Python 3.6。我想使用 FFmpeg 作为 Python 子进程。使用 OSX 嵌入式 Python 2.7 时一切正常,但使用 3.6 时,这不起作用。
我收到一条错误消息,因为它没有找到 FFmepg:
raise FFExecutableNotFoundError("Executable '{0}' not found".format(self.executable))
ffmpy.FFExecutableNotFoundError: Executable 'ffmpeg' not found
我尝试使用 ffmpy,但通过直接调用 FFmpeg 也得到了相同的结果:
>>> from subprocess import call
>>> call(["ffmpeg"])
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
call(["ffmpeg"])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
我安装了 FFmpeg 库。通过终端使用 Brew。它安装得很好,但只有 Python 2.7 可见,3.6 不可见。
从终端调用它正在工作:
$ ffmpeg
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
我(还)不是 Linux 专家,但我认为 3.6 缺少找到 FFmpeg 的路径。
有什么线索可以解决这个烦人的问题吗?
最佳答案
您的特定问题已解决,但让我分享一下我是如何解决相同错误的:
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
任何人的第一 react 都会是检查
ffmpeg
已在相关环境中正确安装。就我而言,我运行了 conda install -c conda-forge ffmpeg
没有错误信息。当我运行 find / -name ffmpeg
,我找到了ffmpeg
目录位于我预期的位置,即 /Users/PatrickT/miniconda3/envs/sp/bin/ffmpeg
.版本为 ffmpeg-4.2.2
.我跑了conda search ffmpeg --channel conda-forge
并发现有可用的更新,所以我再次安装了它,但这次使用的语法略有不同,以防万一:conda config --add channels conda-forge
conda install ffmpeg
而这一次奏效了!
结论:无论出于何种原因
ffmpeg
没有在我的系统上正确安装,而 ffmpeg
目录已在正确的位置创建,调用应用程序失败。简而言之,问题与错误消息所述完全相同:No such file or directory: 'ffmpeg'
关于macos - python3.6 ffmpeg调用MacOSX(关闭),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43297336/