[Osgeo4w-trac] [osgeo4w-dev] [osgeo4w] #569: No module named Tkinter when importing matplotlib

Frank Broniewski hallo at frankbroniewski.com
Thu Apr 19 01:52:35 PDT 2018


Hi,

you don't actually need Tkinter, if you specify

import matplotlib
matplotlib.use('Qt5Agg')

matplotlib will use QT5 (or qt4 if you're on QGIS 2.x) for displaying graphs

HTH
Frank

Dipl. Geogr. Frank Broniewski
Waldhölzbacher Str. 51
66679 Losheim am See
06872 509 068 4
0176 611 26 9 2 6
www.frankbroniewski.com

-----Ursprüngliche Nachricht-----
Von: osgeo4w-dev <osgeo4w-dev-bounces at lists.osgeo.org> Im Auftrag von OSGeo4W
Gesendet: Donnerstag, 19. April 2018 09:34
Cc: osgeo4w-trac at lists.osgeo.org
Betreff: [osgeo4w-dev] [osgeo4w] #569: No module named Tkinter when importing matplotlib

#569: No module named Tkinter when importing matplotlib
-------------------+---------------------------
Reporter:  chau    |      Owner:  osgeo4w-dev@…
    Type:  defect  |     Status:  new
Priority:  major   |  Component:  Package
 Version:          |   Keywords:
-------------------+---------------------------
 I am trying to make the following import in python 2.7.5 from OSGeo (x64):

 {{{import matplotlib.pyplot as plt}}}

 and I get the following error report:

 {{{
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\OSGEO4~1\apps\Python27\lib\site-packages\matplotlib\pyplot.py",
 line 115, in <module>
     _backend_mod, new_figure_manager, draw_if_interactive, _show =
 pylab_setup()
   File "C:\OSGEO4~1\apps\Python27\lib\site-
 packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
     globals(),locals(),[backend_name],0)
   File "C:\OSGEO4~1\apps\Python27\lib\site-
 packages\matplotlib\backends\backend_tkagg.py", line 6, in <module>
     from six.moves import tkinter as Tk
   File "C:\OSGEO4~1\apps\Python27\lib\site-packages\six.py", line 203, in  load_module
     mod = mod._resolve()
   File "C:\OSGEO4~1\apps\Python27\lib\site-packages\six.py", line 115, in  _resolve
     return _import_module(self.mod)
   File "C:\OSGEO4~1\apps\Python27\lib\site-packages\six.py", line 82, in  _import_module
     __import__(name)
 ImportError: No module named Tkinter
 }}}

 I cannot find any {{{Tkinter}}} package in the OSGeo setup package browser  and normally OSGeo is really good at including dependencies.

 My system is Windows 10.

--
Ticket URL: <https://trac.osgeo.org/osgeo4w/ticket/569>
OSGeo4W <http://trac.osgeo.org/osgeo4w>
OSGeo4W is the Windows installer and package environment for the OSGeo stack.


More information about the Osgeo4w-trac mailing list