question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'AudioSegment'

See original GitHub issue

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”

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
jiaarocommented, Jun 18, 2017

I’m not sure this is the issue, but having a file named pydub.py is a red flag. Try renaming it?

1reaction
masoudMZBcommented, Jun 7, 2020

Also having chunk.py filename is red flag. If you have same problem this may help you

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name 'AudioSegment'
Having a file named pydub.py is a red flag. Try renaming it?
Read more >
How to Fix : “ImportError: Cannot import name X” in Python
The following are the major reasons for the occurrence of "ImportError: cannot import name": The imported class is in a circular dependency. The...
Read more >
ImportError: cannot import name 'AudioSegment' - Bountysource
Hi, I installed pudub but I got the follow problem. Steps to reproduce. Run one of these import pydub pydub.
Read more >
signal_processing.py - Google Git
import numpy as np. except ImportError: logging.critical('Cannot import the third-party Python package numpy'). sys.exit(1). try: import pydub.
Read more >
Python报错,发生异常: ImportError cannot import name ...
最近在使用python库pydub进行音频剪辑的时候,遇到了一个奇怪的问题, 发生异常: ImportError cannot import name 'AudioSegment' from 'pydub'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found