import matplotlib.pyplot gives ImportError: No module named _tkagg

Bug #337469 reported by jhn on 2009-03-03
This bug affects 12 people
Affects Status Importance Assigned to Milestone
matplotlib (Ubuntu)

Bug Description

The default TkAgg backend for matplotlib dosn't work and gives the folowing error when
pyplot is imported in both python 2.6 and 2.5

>>> import matplotlib.pyplot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/matplotlib/", line 75, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib/python2.6/dist-packages/matplotlib/backends/", line 25, in pylab_setup
  File "/usr/lib/python2.6/dist-packages/matplotlib/backends/", line 8, in <module>
    import tkagg # Paint image to Tk photo blitter extension
  File "/usr/lib/python2.6/dist-packages/matplotlib/backends/", line 1, in <module>
    import _tkagg
ImportError: No module named _tkagg

However if you change the backend in /etc/matplotlibrc to QT4 (and maybe others) everything works fine

using matplotlib on kubuntu 9.04 alpha 5

Related branches

Václav Šmilauer (eudoxos) wrote :

Confirming. This is a regression from intrepid and cen be verified by inspection of package contents list. doesn't exist anymore in jaunty.

Václav Šmilauer (eudoxos) wrote :

BTW no mention of such change in changelogs, either.

Václav Šmilauer (eudoxos) wrote :

After rebuilding the package locally, installs just fine. OTOH then I get RuntimeError: Could not find the matplotlib data files from /usr/lib/python2.6/dist-packages/matplotlib/ But that one can be worked around by setting MATPLOTLIBDATA=/usr/share/matplotlib env. var.

Václav Šmilauer (eudoxos) wrote :

Correcting my mistake in the last post: should read MATPLOTLIBDATA=/usr/share/matplotlib/mpl-data .

David Coles (dcoles) on 2009-03-12
Changed in matplotlib:
status: New → Confirmed

I find that rebuilding matplotlib addresses the issue, without need for setting the environment variable here.

Andrew Straw (astraw) wrote :

I can confirm this bug with I have a patch to the source and confirmed that it builds the _tkagg module and fixes this bug. I include the debdiff file produced from the source I used.

LaserJock (laserjock) wrote :

Andrew, thanks a ton for the debdiff. One question though, what are the changes in debian/rules for? Why are you rm'ing the build directory?

Andrew Straw (astraw) wrote :

Jordan, the "rm -rf build" is in the clean target -- this is only used for cleaning up the tree after a build and before a new one. "dh-clean build", which I removed, was breaking if the build directory wasn't there, whereas the rm command does not break. Really, I should probably test for the existence of the directory and only delete it in that case, but I couldn't remember the syntax, whereas "rm -rf" is pretty much hardwired into my spinal ganglia.

Benjamin Drung (bdrung) wrote : should be changed to

Benjamin Drung (bdrung) wrote :

I have added the bug number to the changelog entry. I can confirm that this patch works. So please sponsor Andrews patch.

Daniel Holbach (dholbach) wrote :

Uploaded. Sitting in the queue.

Changed in matplotlib (Ubuntu):
status: Confirmed → Fix Committed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package matplotlib -

matplotlib ( jaunty; urgency=low

  * Really build with tcl/tk8.5 as python-tk was build with tcl/tk8.5
    (LP: #337469).

 -- Andrew Straw <email address hidden> Sat, 21 Mar 2009 14:55:09 -0700

Changed in matplotlib:
status: Fix Committed → Fix Released
Youen (youen-peron) wrote :

I have the same bug with an upgraded Nasty from a clean Manvrik. I don't known if i must open a new issue or reopen this one.

Jan Groenewald (jan-aims) wrote :

This bug is present on Natty Development branch at the moment.
Should a new bug be filed?

jan@milaine-laptop:~$ python -c "import pylab"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/pymodules/python2.7/matplotlib/", line 247, in <module>
    from matplotlib.pyplot import *
  File "/usr/lib/pymodules/python2.7/matplotlib/", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/", line 25, in pylab_setup
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/", line 8, in <module>
    import tkagg # Paint image to Tk photo blitter extension
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/", line 1, in <module>
    import _tkagg
ImportError: No module named _tkagg
jan@milaine-laptop:~$ dpkg -l |grep python-tk
ii python-tk 2.7-2ubuntu2 Tkinter - Writing Tk applications with Python

I can confirm that this is an issue in Natty. It happened with today's batch of updates, since it was not a problem yesterday.

Please follow bug #752647 for this issue in Natty.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers