ImportError: cannot import name ‘AudioSegment’

Hi, I installed pudub but I got the follow problem.

Steps to reproduce

Run one of these

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

Actual behavior

With the first one code I got.

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

  File "<ipython-input-256-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 7, in <module>
    import pydub

  File "E:\OneDrive - usach.cl\chillbot\pydub.py", line 8, in <module>
    pydub.AudioSegment.ffmpeg = "C:\ffmpeg\bin"

AttributeError: module 'pydub' has no attribute 'AudioSegment'

with the second I got.

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

  File "<ipython-input-257-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 7, in <module>
    from pydub import AudioSegment

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

ImportError: cannot import name 'AudioSegment'

Your System configuration

  • Python version: 3.6.1 64 bits, windows 10 with anaconda
  • Pydub version: The default by pip install
  • ffmpeg or avlib?: ffmpeg
  • ffmpeg/avlib version: FFmpeg 3.3 “Hilbert”

Read more here: Source link