Home > Software engineering >  No file or directory: 'ffmpeg' on MacOS in Python
No file or directory: 'ffmpeg' on MacOS in Python

Time:02-03

I am using MacOS (Apple Silicon) and I am trying to use the whisper module from OpenAI in Python. My code is this:

import whisper

file_path = "4547.mp3"
model = whisper.load_model("base")

result = model.transcribe(file_path)
print(result["text"])

When running that code I get the error:

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

I think it is because Python is looking in the wrong folder for ffmpeg and therefore can't find it, but I don't know how to fix that if that is the issue.

I have installed homebrew and used the command 'brew install ffmpeg' and it has successfully installed with no errors. I have tried uninstalling ffmpeg and reinstalling it, uninstalling open_whisper and reinstalling it, and installing ffmpeg-python but it still doesn't fix this issue.

CodePudding user response:

The library you're trying to use requires another package or another app named ffmpeg . Just install it it must fix the issue.

First try installing ffmpeg package within python by running this command :

pip install ffmpeg

If that doesn't work try downloading ffmpeg app for your os which is macOS and install it and run the code again. I found this guide on how to install package manually, hope it helps. Thank You.

CodePudding user response:

You need to drag the file into the directory with your cursor. Your directory should be your python project. If you do not have a python project, create a folder to which you can put both files in that folder.

  • Related