Python – How to import wave library in python?

pythonpython-import

I tried to import in my code library wave (istalled by pip) like this:

import wave

And next what I used in my program is

raw = wave.open('file.wav', 'rb')

After run my program in console I had this wierd problem:

AttributeError: 'module' object has no attribute 'open'

What is the problem?

Best Answer

You probably have a local file named wave.py that is being imported instead.

Check with:

import wave

print wave.__file__

and rename or delete that file.