ImportError:无法导入名称'AudioSegment'

时间:2017-06-18 00:23:06

标签: python python-3.x pydub

我正在尝试使用库pydub,但是当我运行脚本时,我得到了这个。

runfile('E:/OneDrive - usach.cl/chillbot/pydub.py', wdir='E:/OneDrive - usach.cl/chillbot')
Traceback (most recent call last):

  File "<ipython-input-203-a38a65fe4502>", line 1, in <module>
    runfile('E:/OneDrive - usach.cl/chillbot/pydub.py', wdir='E:/OneDrive - usach.cl/chillbot')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "E:/OneDrive - usach.cl/chillbot/pydub.py", line 9, in <module>
    from pydub import AudioSegment

  File "E:\OneDrive - usach.cl\chillbot\pydub.py", line 9, in <module>
    from pydub import AudioSegment

ImportError: cannot import name 'AudioSegment'

我没有找到有关错误的信息,我正在使用带有anaconda的Windows 10,我正在运行的代码是。

from pydub import AudioSegment
AudioSegment.ffmpeg = "C:\ffmpeg\bin"

song = AudioSegment.from_mp3("I_eat_Plants_for_a_living-Unfaithful.mp3")

如果删除除from pydub import AudioSegment以外的所有代码,我会收到同样的错误。

1 个答案:

答案 0 :(得分:1)

拥有一个名为pydub.py的文件是一个红旗。尝试重命名吗?