1

I am developing a QGIS-plugin and for graphing I want to use matplotlib, like many other QGIS -plugins.

This worked fine under linux, but under windows with QGIS2.4 I am experiencing problems.

I checked and matplotlib seams to be included in the standard windows-install of QGIS. But when people try to install the plugin, they get this report:

The plugin is broken: No Module named tkinter

Turns out even though I'm using pyqt, matplotlib requires tkinter and this seams be to be excluded from the QGIS installation.

Is this a Bug? (should i report it?)

Or is there a way to use matplotlib without loading tkinter?

If I really need tkinter, how can I solve this? As tkinter is a binary python package, i can't include it in my plugin or is there an alternative (pyQWT is also binary, so also not a solution)

I call matplotlib this way:

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
import matplotlib.pyplot as plt

its the experimental version (1.2.0) of this plugin, if you want to try it: http://plugins.qgis.org/plugins/geopunt4Qgis/

asked Jul 9, 2014 at 16:46
4
  • How did you call matplotlib, with a specific backend (matplotlib backends) ? Commented Jul 9, 2014 at 16:58
  • Are they using the stand-alone installer or the OSGeo4W installer? Commented Jul 9, 2014 at 17:15
  • matplotlib works without problem with the standalone installer Commented Jul 9, 2014 at 17:22
  • standalone 64bit. Commented Jul 9, 2014 at 18:18

2 Answers 2

2

OK i found the problem. I made following changes to my code so it doesn't try load tkinter anymore:

I changed:

 import matplotlib.pyplot as plt

into:

 from matplotlib.figure import Figure
 from matplotbib import axes

and change plt.figure() in Figure() etc..

answered Jul 10, 2014 at 8:42
1

I have found the solution here : https://github.com/gem/oq-irmt-qgis/issues/224. Some plugins blocks access to the tkinter module.

answered Aug 2, 2017 at 15:35
1
  • very good finding. Following this link I also found the solution to the problem. Thanks a lot for that! Commented Oct 24, 2020 at 20:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.