title: I can't run a simple code using pyaudio - [Errno -9996] Invalid output device (no default output device)
body: <p>(I'm new at python)</p>
  
  <p>I'm trying to run a simple code about pyaudio. I just copied and pasted a code that I found on the pyaudio web site.</p>
  
  <p>I get this error:</p>
  
  <pre><code>    OSError                                   Traceback (most recent call last)
  &lt;ipython-input-7-3fc52ceecbf3&gt; in &lt;module&gt;()
       15                 channels=wf.getnchannels(),
       16                 rate=wf.getframerate(),
  ---&gt; 17                 output=True)
       18 
       19 # read data
  
  /home/gustavolg/anaconda3/lib/python3.5/site-packages/pyaudio.py in open(self, *args, **kwargs)
      748         """
      749 
  --&gt; 750         stream = Stream(self, *args, **kwargs)
      751         self._streams.add(stream)
      752         return stream
  
  /home/gustavolg/anaconda3/lib/python3.5/site-packages/pyaudio.py in __init__(self, PA_manager, rate, channels, format, input, output, input_device_index, output_device_index, frames_per_buffer, start, input_host_api_specific_stream_info, output_host_api_specific_stream_info, stream_callback)
      439 
      440         # calling pa.open returns a stream object
  --&gt; 441         self._stream = pa.open(**arguments)
      442 
      443         self._input_latency = self._stream.inputLatency
  
  OSError: [Errno -9996] Invalid output device (no default output device)
  </code></pre>
  
  <p>I can not figure out how to solve this error. I don't know if this has something to do with audio driver or if the code needs an output declaration. I mean, if I have to select an output.</p>
  
  <p>The code:</p>
  
  <pre><code>import pyaudio
  import wave
  import sys
  
  CHUNK = 1024
  
  
  wf = wave.open("/home/gustavolg/anaconda3/aPython/file.wav", 'rb')
  
  # instantiate PyAudio (1)
  p = pyaudio.PyAudio()
  
  # open stream (2)
  stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
                  channels=wf.getnchannels(),
                  rate=wf.getframerate(),
                  output=True)
  
  # read data
  data = wf.readframes(CHUNK)
  
  # play stream (3)
  while len(data) &gt; 0:
      stream.write(data)
      data = wf.readframes(CHUNK)
  
  # stop stream (4)
  stream.stop_stream()
  stream.close()
  
  # close PyAudio (5)
  p.terminate()
  </code></pre>
  
  <p>I'm using python3 on Jupyter notebook.</p>