1

ich ein einfaches Notebook mit dem folgenden Code haben:matplotlib - Import: Kein Modul namens _tkinter

%matplotlib inline 

Allerdings, wenn es läuft bekomme ich folgende Fehlermeldung:

ImportError: No module named _tkinter 

Ich habe ein anderes Notebook im gleichen Projekt, und dass man die Anweisung ohne Problem ausführen kann.

Die Data Science-Erfahrung ist ein Managed Service, so dass Sie keinen Root-Zugang haben, um _tkinter zu installieren.

Vollstacktrace:

ImportErrorTraceback (most recent call last) 
<ipython-input-43-5f9c00ae8c2d> in <module>() 
----> 1 get_ipython().magic(u'matplotlib inline') 
     2 
     3 import matplotlib.pyplot as plt 
     4 #import numpy as np 
     5 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s) 
    2161   magic_name, _, magic_arg_s = arg_s.partition(' ') 
    2162   magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) 
-> 2163   return self.run_line_magic(magic_name, magic_arg_s) 
    2164 
    2165  #------------------------------------------------------------------------- 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line) 
    2082     kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 
    2083    with self.builtin_trap: 
-> 2084     result = fn(*args,**kwargs) 
    2085    return result 
    2086 

<decorator-gen-106> in matplotlib(self, line) 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k) 
    191  # but it's overkill for just that one bit of state. 
    192  def magic_deco(arg): 
--> 193   call = lambda f, *a, **k: f(*a, **k) 
    194 
    195   if callable(arg): 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line) 
    98    print("Available matplotlib backends: %s" % backends_list) 
    99   else: 
--> 100    gui, backend = self.shell.enable_matplotlib(args.gui) 
    101    self._show_matplotlib_backend(args.gui, backend) 
    102 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui) 
    2949     gui, backend = pt.find_gui_and_backend(self.pylab_gui_select) 
    2950 
-> 2951   pt.activate_matplotlib(backend) 
    2952   pt.configure_inline_support(self, backend) 
    2953 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in activate_matplotlib(backend) 
    293  matplotlib.rcParams['backend'] = backend 
    294 
--> 295  import matplotlib.pyplot 
    296  matplotlib.pyplot.switch_backend(backend) 
    297 

/gpfs/fs01/user/sdd1-7e9fd7607be53e-39ca506ba762/.local/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>() 
    112 
    113 from matplotlib.backends import pylab_setup 
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() 
    115 
    116 _IP_REGISTERED = None 

/gpfs/fs01/user/sdd1-7e9fd7607be53e-39ca506ba762/.local/lib/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, 
---> 32        globals(),locals(),[backend_name],0) 
    33 
    34  # Things we pull in from all backends 

/gpfs/fs01/user/sdd1-7e9fd7607be53e-39ca506ba762/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py in <module>() 
     4 
     5 from matplotlib.externals import six 
----> 6 from matplotlib.externals.six.moves import tkinter as Tk 
     7 from matplotlib.externals.six.moves import tkinter_filedialog as FileDialog 
     8 

/gpfs/fs01/user/sdd1-7e9fd7607be53e-39ca506ba762/.local/lib/python2.7/site-packages/matplotlib/externals/six.pyc in load_module(self, fullname) 
    197   mod = self.__get_module(fullname) 
    198   if isinstance(mod, MovedModule): 
--> 199    mod = mod._resolve() 
    200   else: 
    201    mod.__loader__ = self 

/gpfs/fs01/user/sdd1-7e9fd7607be53e-39ca506ba762/.local/lib/python2.7/site-packages/matplotlib/externals/six.pyc in _resolve(self) 
    111 
    112  def _resolve(self): 
--> 113   return _import_module(self.mod) 
    114 
    115  def __getattr__(self, attr): 

/gpfs/fs01/user/sdd1-7e9fd7607be53e-39ca506ba762/.local/lib/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.""" 
---> 80  __import__(name) 
    81  return sys.modules[name] 
    82 

/usr/local/src/bluemix_jupyter_bundle.v20/notebook/lib/python2.7/lib-tk/Tkinter.py in <module>() 
    37  # Attempt to configure Tcl/Tk without requiring PATH 
    38  import FixTk 
---> 39 import _tkinter # If this fails your Python may not be configured for Tk 
    40 tkinter = _tkinter # b/w compat for export 
    41 TclError = _tkinter.TclError 

ImportError: No module named _tkinter 
+0

Die datascienceexperience ist ein Managed Service, so dass Sie keinen Root-Zugriff haben. –

Antwort

2

So war das Update ganz einfach - ich musste nur den Kernel starten Sie den Kernel-Menüpunkt im Notebook.

Ich hatte das gleiche Problem beim lokalen Ausführen von ipython auf meinem Laptop und die Lösung war, tkinter zu installieren, so dass ich nicht erwartet hatte, die Antwort so einfach wie den Kernel neu zu starten.

Ein anderes Mal, als ich diese Fehlermeldung erhielt, Neustart des Kernels hat nicht funktioniert. Ich musste:

  • Änderung der Funke Backend
  • herunterladen das Notebook
  • löschen Sie das Notebook in DSX Datei
  • erstellen ein neues Notebook aus der heruntergeladenen Notebook