title: Jupyter Notebook + Matplotlib; Freeze on plot.show()
body: <p><strong>OBJECTIVE</strong></p>
  
  <ul>
  <li>Use Matplotlib to plot the state of Texas</li>
  </ul>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>import pandas as pd
  import numpy as np
  matplotlib.use('QT4Agg')
  import matplotlib
  import matplotlib.pyplot as plt
  import matplotlib.cm as cm
  from matplotlib.colors import Normalize
  from matplotlib.collections import PatchCollection
  import matplotlib.pyplot as plt
  from mpl_toolkits.basemap import Basemap
  
  
  map = Basemap(projection='merc', lat_0 = 57, lon_0 = -135,
      resolution = 'h', area_thresh = 0.1,
      llcrnrlon=-106.65, llcrnrlat=25.83,
      urcrnrlon=-93.50, urcrnrlat=36.50)
  
  map.drawcoastlines()
  map.drawstates()
  map.drawcountries()
  map.fillcontinents(color = 'white')
  map.drawmapboundary()
  
  
  plt.show(block = False)
  </code></pre>
  
  <p><strong>OUTPUT</strong></p>
  
  <p><a href="https://i.stack.imgur.com/7PCty.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7PCty.png" alt="enter image description here"></a></p>
  
  <p><strong>DEBUG</strong></p>
  
  <ul>
  <li><p>Apparently <a href="https://github.com/matplotlib/matplotlib/issues/6908" rel="nofollow noreferrer">changing backend helps</a>, however <code>matplotlib.use('QT4Agg')</code> yields the following error <code>"Gtk* backend requires pygtk to be installed"</code></p></li>
  <li><p>Looked online for solutions, read you had to install <a href="https://stackoverflow.com/questions/4930524/how-can-i-set-the-backend-in-matplotlib-in-python">PyGTK</a>, however, when installing, I receive the following error: <code>Building PyGTK using distutils is only supported on windows.</code> (after inputting <code>pip install PyGTK</code>)</p></li>
  <li><p>Additionally, despite calling <code>matplotlib.use('QT4Agg')</code>, I receive the error <code>matplotlib.use() has no effect
  because the backend has already been chosen;
  matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
  or matplotlib.backends is imported for the first time.</code>.</p></li>
  </ul>
  
  <p><strong>ISSUE</strong></p>
  
  <ol>
  <li>Cannot properly install packages necessary to prevent matplotlib from running in a continual loop. Am I missing something here? Are there workarounds?</li>
  <li>Why, despite calling <code>matplotlib('QT4Agg')</code> before importing matplotlib, I receive the error (bullet point #3) listed above?</li>
  </ol>