2

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • What library is this? Clearly there is not `open` function in that library, but we cannot help you more than that. – Martijn Pieters Jan 17 '13 at 22:41
  • Can you give us a bit more information? Specifically -- which version of Python are you using? And what is the whole error traceback? I can't replicate your problem on either Python 2.7.1 or Python 3.2.3 – necaris Jan 17 '13 at 22:43
  • 2
    Do you mean the [standard library `wave`](http://docs.python.org/2/library/wave.html) that comes with Python? Check that you don't have a local file named `wave.py` first. – Martijn Pieters Jan 17 '13 at 22:43
  • wave library is used to manipulate .wav files (standard library http://docs.python.org/2.6/library/wave.html) – Radosław Rosłaniec Jan 17 '13 at 22:43
  • `wave` comes with Python: http://docs.python.org/2/library/wave.html It does have an `open` method on my system. – Thomas Jan 17 '13 at 22:43

1 Answers1

9

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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343