title: Matplotlib, Jupyter Notebook: ImportError: No module named Tkinter
body: <h3>This question is different from <a href="https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter">ImportError: No module named 'Tkinter'</a>, read clearfuly before you vote down!</h3>
  
  <h3>Env:</h3>
  
  <ul>
  <li>Python 2.7</li>
  <li>CentOS 7</li>
  <li>matplotlib 1.5.3</li>
  <li>notebook 4.1.0</li>
  </ul>
  
  <h3>Installation:</h3>
  
  <pre><code>install it by pip
  </code></pre>
  
  <h3>Show my code</h3>
  
  <pre><code>import gzip, binascii, struct, numpy
  import matplotlib.pyplot as plt
  
  with gzip.open(test_data_filename) as f:
      # Print the header fields.
      for field in ['magic number', 'image count', 'rows', 'columns']:
          # struct.unpack reads the binary data provided by f.read.
          # The format string '&gt;i' decodes a big-endian integer, which
          # is the encoding of the data.
          print(field, struct.unpack('&gt;i', f.read(4))[0])
  
      # Read the first 28x28 set of pixel values. 
      # Each pixel is one byte, [0, 255], a uint8.
      buf = f.read(28 * 28)
      image = numpy.frombuffer(buf, dtype=numpy.uint8)
  
      # Print the first few values of image.
      print('First 10 pixels:', image[:10])
  </code></pre>
  
  <h3>Show the bug</h3>
  
  <pre><code>ImportErrorTraceback (most recent call last)
  &lt;ipython-input-9-8ba574e10b9a&gt; in &lt;module&gt;()
        3 
        4 import gzip, binascii, struct, numpy
  ----&gt; 5 import matplotlib.pyplot as plt
        6 
        7 
  
  /usr/lib64/python2.7/site-packages/matplotlib/pyplot.py in &lt;module&gt;()
      112 
      113 from matplotlib.backends import pylab_setup
  --&gt; 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
      115 
      116 _IP_REGISTERED = None
  
  /usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
       30     # imports. 0 means only perform absolute imports.
       31     backend_mod = __import__(backend_name,
  ---&gt; 32                              globals(),locals(),[backend_name],0)
       33 
       34     # Things we pull in from all backends
  
  /usr/lib64/python2.7/site-packages/matplotlib/backends/backend_tkagg.py in &lt;module&gt;()
        4 
        5 from matplotlib.externals import six
  ----&gt; 6 from matplotlib.externals.six.moves import tkinter as Tk
        7 from matplotlib.externals.six.moves import tkinter_filedialog as FileDialog
        8 
  
  /usr/lib64/python2.7/site-packages/matplotlib/externals/six.pyc in load_module(self, fullname)
      197         mod = self.__get_module(fullname)
      198         if isinstance(mod, MovedModule):
  --&gt; 199             mod = mod._resolve()
      200         else:
      201             mod.__loader__ = self
  
  /usr/lib64/python2.7/site-packages/matplotlib/externals/six.pyc in _resolve(self)
      111 
      112     def _resolve(self):
  --&gt; 113         return _import_module(self.mod)
      114 
      115     def __getattr__(self, attr):
  
  /usr/lib64/python2.7/site-packages/matplotlib/externals/six.pyc in _import_module(name)
       78 def _import_module(name):
       79     """Import module, returning the module after the last dot."""
  ---&gt; 80     __import__(name)
       81     return sys.modules[name]
       82 
  
  ImportError: No module named Tkinter
  </code></pre>
  
  <h3>TKinter</h3>
  
  <pre><code>Python 2.7.5 (default, Sep 15 2016, 22:37:39) 
  [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import Tkinter
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ImportError: No module named Tkinter
  &gt;&gt;&gt; 
  </code></pre>
  
  <h3>How did this occured</h3>
  
  <p>There is a <a href="http://jupyter-notebook.readthedocs.io/en/latest/public_server.html" rel="nofollow noreferrer">Jupyter Notebook Server </a> running a on a remote CentOS Server, and I access the notebook via my local web-browser, and when I type the above code in the jupyter notebook, the bug occurs!!!</p>
  
  <p>How can fix this bug? Thank you!</p>