Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'ffmpeg' has no attribute 'input' #174

Open
iamtahirkhan6 opened this issue Mar 9, 2019 · 43 comments
Open

AttributeError: module 'ffmpeg' has no attribute 'input' #174

iamtahirkhan6 opened this issue Mar 9, 2019 · 43 comments

Comments

@iamtahirkhan6
Copy link

Traceback (most recent call last):
File "/main/ffmpeg.py", line 1, in
import ffmpeg
File "/main/ffmpeg.py", line 2, in
stream = ffmpeg.input('video.mp4')
AttributeError: module 'ffmpeg' has no attribute 'input'

@kkroening
Copy link
Owner

pip install ffmpeg-python
instead of
pip install ffmpeg

@muellermartin
Copy link

I had the same error, because python-ffmpeg was installed instead of ffmpeg-python. Therefore this can be considered as fixed.

@hldh214
Copy link

hldh214 commented Jul 23, 2019

try another filename (don't use same name as your imported package)

@tung-nguyen-uet
Copy link

tung-nguyen-uet commented Sep 12, 2019

It doesn't solve my problem.
I have install pip install ffmpeg-python

import ffmpeg
filep = '/path/to/my/file.mp4'
stream = ffmpeg.input(filep)
Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'ffmpeg' has no attribute 'input'

@vinooo1095
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python.
uninstall both with:
pip uninstall ffmpeg
pip uninstall ffmpeg-python

and install ffmpeg-python again with :
pip install ffmpeg-python

This solved the problem in my system :)

@shgninc
Copy link

shgninc commented Jun 21, 2020

I have same problem, install and uninstall the module multiple times.

but i forgot to install ffmpeg package.

@nlsdvl
Copy link

nlsdvl commented Oct 6, 2020

you will probably end up with that exact error if you do :
pip install python-ffmpeg

instead of :
pip install ffmpeg-python

at least, I did ...

@CharlesChen-ccc
Copy link

CharlesChen-ccc commented Nov 17, 2020

  1. Make sure you had pip install ffmpeg-python
  2. You should copy the ffmpeg.exe to you ***.py file work directory
    3c211f825bfb22c465eb9ea41706ec0

LuisMayo added a commit to LuisMayo/objection_engine that referenced this issue Jan 27, 2021
The use of "mmpeg" library was throwing `"AttributeError: module 'ffmpeg' has no attribute 'input'"`

That was due to the incorrect "ffmpeg" library being installed. It seems the intended library is in fact [ffmpeg-python](https://github.com/kkroening/ffmpeg-python).
More info in this issue: kkroening/ffmpeg-python#174
@rupshac
Copy link

rupshac commented Mar 9, 2021

If I install ffmpeg + ffmpeg-python I see the same issue.

If I install only ffmpeg-python I see "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

@hobbitsyfeet
Copy link

hobbitsyfeet commented Mar 11, 2021

Traceback (most recent call last):
File "/main/ffmpeg.py", line 1, in
import ffmpeg
File "/main/ffmpeg.py", line 2, in
stream = ffmpeg.input('video.mp4')
AttributeError: module 'ffmpeg' has no attribute 'input'

If you're silly like me and create a file named ffmpeg.py to test things out, the first command you call is obviously ffmpeg.input(...). Since you're re-defining ffmpeg it does not contain ffmpeg.input.

Therefore, AttributeError: module 'ffmpeg' has no attribute 'input'

The solution to this: Make sure your Python file isn't named ffmpeg.py

@784682065
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python.
uninstall both with:
pip uninstall ffmpeg
pip uninstall ffmpeg-python

and install ffmpeg-python again with :
pip install ffmpeg-python

This solved the problem in my system :)

thank you! If it wasn't for you, I would have been tortured to death.

@ShawKai666
Copy link

step 1:sudo apt install ffmpeg
step 2:pip install ffmpeg-python
step 3:pip uninstall ffmpeg

@KalininY
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

Thank you very much!

@lixueqidaytoy
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

Thanks, you help me a lot!

@mikhail-okrochkov
Copy link

I've tried all of the above solutions, I either get
"FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

or

AttributeError: module 'ffmpeg' has no attribute 'input'

I've tried uninstall and re-installing in various different orders

@lixueqidaytoy
Copy link

I've tried all of the above solutions, I either get "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

or

AttributeError: module 'ffmpeg' has no attribute 'input'

I've tried uninstall and re-installing in various different orders

I still have this problem in the Jupyter notebook, so I use vs code.
AttributeError: module 'ffmpeg' has no attribute 'input' this can be solved, but I get new error.

AttributeError: module 'ffmpeg' has no attribute 'run'

if you get this, you just need to turn colored frames into video.

@mikhail-okrochkov
Copy link

I'm working in vscode and I still run into this issue.

@gyq517
Copy link

gyq517 commented Jun 9, 2022

I've tried all of the above solutions, I either get "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

or

AttributeError: module 'ffmpeg' has no attribute 'input'

I've tried uninstall and re-installing in various different orders

I had the same problem until I tried sudo apt install ffmpeg

@johntsunami
Copy link

The answer is here. You probably didn't install ffmpeg completely and setup the environmental variables. Link shows all the steps.

https://stackoverflow.com/questions/54262306/ffmpeg-python-wrapper-ffmpeg-run-getting-filenotfounderror

@orange5E06
Copy link

May your interpreter has no ffmpeg-python

@ZZZsleepyheadZZZ
Copy link

I used conda install -c conda-forge ffmpeg, and it works. It turned out that ffmpeg installed by pip was of a too old version.

@459737087
Copy link

pip install python-ffmpeg

this is right

@dinuthomas
Copy link

Finally worked for me after doing this,

  1. pip uninstall ffmpeg-python
  2. pip3 install ffmpeg-python

So try installing with pip3..

@Suvi-dha
Copy link

This worked for me:

  1. uninstall ffmpeg-python
  2. pip install ffmpeg
  3. pip install ffmpeg-python

@githmashwinkumar
Copy link

I have a very simple code -
[
import whisper

model = whisper.load_model("base")
result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False)
print(result["text"])
]

Have tried with "pip install python-ffmpeg" when it gave the error - "AttributeError: module 'ffmpeg' has no attribute 'Error'". Then tried with "pip install ffmpeg" and "pip install ffmpeg-python". Now it is throwing this error
[
Traceback (most recent call last):
File "D:\Newfolder\ds\ML\patrec\rec.py", line 4, in
result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False)
File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\transcribe.py", line 121, in transcribe
mel = log_mel_spectrogram(audio, padding=N_SAMPLES)
File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 130, in log_mel_spectrogram
audio = load_audio(audio)
File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 46, in load_audio
ffmpeg.input(file, threads=0)
File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 313, in run
process = run_async(
File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 284, in run_async
return subprocess.Popen(
File "C:\py39\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\py39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
]
Can you please suggest a way-forward for addressing this?

@pardon-hnu
Copy link

Thanks. you are my hero!It works

@githmashwinkumar
Copy link

I have a very simple code - [ import whisper

model = whisper.load_model("base") result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) print(result["text"]) ]

Have tried with "pip install python-ffmpeg" when it gave the error - "AttributeError: module 'ffmpeg' has no attribute 'Error'". Then tried with "pip install ffmpeg" and "pip install ffmpeg-python". Now it is throwing this error [ Traceback (most recent call last): File "D:\Newfolder\ds\ML\patrec\rec.py", line 4, in result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 130, in log_mel_spectrogram audio = load_audio(audio) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 46, in load_audio ffmpeg.input(file, threads=0) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 313, in run process = run_async( File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 284, in run_async return subprocess.Popen( File "C:\py39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\py39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ] Can you please suggest a way-forward for addressing this?

Installing System.Speech from nuget manager resolved this issue. Refered to this link

@raduking
Copy link

raduking commented May 11, 2023

I have a very simple code - [ import whisper

model = whisper.load_model("base") result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) print(result["text"]) ]

Have tried with "pip install python-ffmpeg" when it gave the error - "AttributeError: module 'ffmpeg' has no attribute 'Error'". Then tried with "pip install ffmpeg" and "pip install ffmpeg-python". Now it is throwing this error [ Traceback (most recent call last): File "D:\Newfolder\ds\ML\patrec\rec.py", line 4, in result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 130, in log_mel_spectrogram audio = load_audio(audio) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 46, in load_audio ffmpeg.input(file, threads=0) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 313, in run process = run_async( File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 284, in run_async return subprocess.Popen( File "C:\py39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\py39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ] Can you please suggest a way-forward for addressing this?

As @vinooo1095 suggested already:

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python.

Uninstall both with:

pip3 uninstall ffmpeg
pip3 uninstall ffmpeg-python

Then ONLY install ffmpeg-python again with:

pip3 install ffmpeg-python

@githmashwinkumar
Copy link

githmashwinkumar commented May 11, 2023 via email

@pablodz
Copy link

pablodz commented Jun 15, 2023

Still relevant

@jlmmunix
Copy link

sudo pip uninstall ffmpeg
sudo pip3 uninstall ffmpeg
sudo python -m pip uninstall ffmpeg
sudo python3 -m pip uninstall ffmpeg
sudo pip show ffmpeg
sudo pip show python-ffmpeg
sudo pip3 show ffmpeg
sudo pip3 show python-ffmpeg
sudo pip install ffmpeg-python
sudo pip3 install ffmpeg-python
sudo pip3 install ffmpeg-python
pip install ffmpeg-python --user
python3 -m pip install ffmpeg-python
pip install --ignore-installed ffmpeg-python
pip3 install --ignore-installed ffmpeg-python
python -m pip install --ignore-installed ffmpeg-python
python3 -m pip install --ignore-installed ffmpeg-python

@aronweiler
Copy link

So I ran into this issue today and came here to see a ton of people talking about solutions that don't work... the real solution here (besides making sure you have ffmpeg and ffmpeg-python installed) is to install ffmpeg manually so that you can access the executables.

Whisper is attempting to call ffmpeg by just invoking the "ffmpeg" command line. No pathing is taken into account in these libraries, so you need to install ffmpeg AND make sure it's callable from your python application.

Manual ffmpeg installation steps

  1. Navigate to https://ffmpeg.org/download.html
  2. Download (or clone and then build) the desired build of ffmpeg
  3. Extract the files if you downloaded it
  4. Add the bin path to your environment path

@L-a-n-s-c-e
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

Thanks I was bout to go crazy restarting and reinstalling ffmpeg over and over.

@AlvinKimata
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

This worked for me. Thanks a lot!

@desaiankitb
Copy link

desaiankitb commented Sep 5, 2023

For me none of the above solutions worked. However, the following did worked. I was using this in ipynb you can modify the commands as per your environments. Don't change the sequence.

! apt-get --purge autoremove
! yes | pip uninstall ffmpeg
! yes | pip uninstall ffmpeg-python
! yes | apt-get -y install ffmpeg
! yes | conda install -c conda-forge ffmpeg-python
! yes | pip install ffmpeg-python 

@101is5
Copy link

101is5 commented Sep 6, 2023

This is how it worked for me:

  • install ffmpeg through choco or scoop, as mentioned here (Apparently, it's different than through pip);
  • install ffmpeg-python through python -m pip install ffmpeg-python, or run pip install -U openai-whisper, which installs ffmpeg-python.

Before that, I had come across 3 types of errors when swaping between ffmpeg and ffmpeg-python pip instalations:

  • with ffmpeg or both installed:
module 'ffmpeg' has no attribute 'Error'
AttributeError: module 'ffmpeg' has no attribute 'input'

During handling of the above exception, another exception occurred:

  File "C:\Users\[me]\Documents\programacao\testwhisper\wsp.py", line 5, in <module>
    text = model.transcribe("audio.mp3")
AttributeError: module 'ffmpeg' has no attribute 'Error'
  • with ffmpeg-python only:
Exception has occurred: FileNotFoundError
[WinError 2] O sistema não pode encontrar o arquivo especificado
  File "C:\Users\[me]\Documents\programacao\testwhisper\wsp.py", line 5, in <module>
    text = model.transcribe("audio.mp3")
FileNotFoundError: [WinError 2] O sistema não pode encontrar o arquivo especificado

By the way, pip install hasn't worked for me in a while. It's been only python -m pip install ..., otherwise I get a "not accessed by Pylance" error and, if I try running the script, I get:

No module named 'ffmpeg'
  File "C:\Users\[me]\Documents\programacao\testwhisper\wsp.py", line 2, in <module>
    import whisper
ModuleNotFoundError: No module named 'ffmpeg'

@luoshuiyang
Copy link

step 1:sudo apt install ffmpeg step 2:pip install ffmpeg-python step 3:pip uninstall ffmpeg

I solved the problem using this method,thank you very much.Even solved other problem with this solution.

@SiNaPsEr0x
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python.
uninstall both with:
pip uninstall ffmpeg
pip uninstall ffmpeg-python
and install ffmpeg-python again with :
pip install ffmpeg-python
This solved the problem in my system :)

thank you! If it wasn't for you, I would have been tortured to death.

thanks for solution on docker its ok!

@LeviArckman
Copy link

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

doesn't work

@Xoro399
Copy link

Xoro399 commented Dec 19, 2024

Reinstall ffmpeg

@moluuser
Copy link

pip install ffmpeg
pip uninstall ffmpeg -y
pip install python-ffmpeg
pip uninstall python-ffmpeg -y
pip install ffmpeg-python
pip uninstall ffmpeg-python -y

Then

pip install ffmpeg-python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests