why am i getting error when importing AudioSegment?

拟墨画扇 提交于 2019-12-22 13:45:09

问题


i'm trying to use pydub, but when i import it to python with AudioSegment it will give me an error saying it doesn't recognize it. i tried using pip install and searching online. any help?? i'm using python 2.7

from pydub import AudioSegment

回答1:


Can u uninstall and try installing using pip install pydub. Also make sure pydub path is in the PYTHONPATH or system PATH. What OS are you using?

find out where pydub got installed.
I've in C:\Python27\Lib\site-packages\pydub.
Open a command-prompt and type in ,
set PATH=c:\Python27\Scripts;c:\Python27\Lib;C:\Python27\Lib\sit‌​e-packages\pydub;%PA‌​TH%

Then try running pydub program on cmd screen. Once successful you will need to add pydub path to system environment variables section.

Also for error:

RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)

Looks like pydub cant find ffmpeg or avconv. You may need to install or add path to system. If it's working I would let it be. It's just warning anyway




回答2:


I was also getting the same issue .and it was coming due to ffmpeg was not correctly configured. i have download latest ffmpeg from official website https://www.ffmpeg.org/download.html and setting up the class path worked for me




回答3:


What worked for me was:

  1. Google for a suitable ffmpeg download. I needed a windows 64 bit package, which I downloaded from https://ffmpeg.zeranoe.com/builds/
  2. Opened the downloaded zip file. Then took the files inside the bin folder and placed those inside the pydub folder.

Since i have already placed pydub in the system PATH previously, this removed the need to update the system PATH. The files can be placed elsewhere and that should work as well as long as the PATH is updated.




回答4:


I'm getting the same error because ffmpeg wasn't installed on my MAC. Installed it with brew install ffmpeg and fixed the problem.



来源:https://stackoverflow.com/questions/43169620/why-am-i-getting-error-when-importing-audiosegment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!