"import pylab" in a python console flags error "No module named _tkagg"

Bug #752647 reported by Manjul Apratim
72
This bug affects 14 people
Affects Status Importance Assigned to Milestone
matplotlib (Debian)
Fix Released
Unknown
matplotlib (Ubuntu)
Fix Released
High
Andres Rodriguez
Natty
Fix Released
High
Andres Rodriguez

Bug Description

I upgraded from Maverick to Natty Beta 1 yesterday evening. Upon firing up a python console and issuing "import pylab" I get the following error:

manjul@chaar:~$ python
Python 2.7.1+ (r271:86832, Mar 24 2011, 00:39:14)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/pymodules/python2.7/matplotlib/pylab.py", line 247, in <module>
    from matplotlib.pyplot import *
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 8, in <module>
    import tkagg # Paint image to Tk photo blitter extension
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/tkagg.py", line 1, in <module>
    import _tkagg
ImportError: No module named _tkagg
>>>

The module was fully functional before the upgrade. All python packages have been installed from the repos and there has been no customization so far.

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: python-matplotlib 0.99.3-1ubuntu3
ProcVersionSignature: Ubuntu 2.6.38-8.40-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic i686
NonfreeKernelModules: wl
Architecture: i386
Date: Wed Apr 6 11:45:56 2011
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release i386 (20100429)
ProcEnviron:
 LANGUAGE=en_US:en
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: matplotlib
UpgradeStatus: Upgraded to natty on 2011-04-06 (0 days ago)

Related branches

Revision history for this message
Manjul Apratim (manzdagratiano) wrote :
Revision history for this message
icb410 (ian-berke) wrote :

This was working before a recent update to python-matplotlib a day or so ago. I'm now running 0.99.3-1ubuntu3 also

Revision history for this message
Julian Taylor (jtaylor) wrote :

the _tkagg.so extension did not get built in the ubuntu3 revision:

debdiff python-matplotlib_0.99.3-1ubuntu3_amd64.deb python-matplotlib_0.99.3-1ubuntu2_amd64.deb
[The following lists of changes regard files as different if they have
different names, permissions or owners.]

Files in second .deb but not in first
-------------------------------------
-rw-r--r-- root/root /usr/lib/pyshared/python2.6/matplotlib/backends/_tkagg.so
-rw-r--r-- root/root /usr/lib/pyshared/python2.7/matplotlib/backends/_tkagg.so

Files in first .deb but not in second
-------------------------------------
-rw-r--r-- root/root /usr/share/doc/python-matplotlib/changelog.Debian.gz

Control files: lines which differ (wdiff format)
------------------------------------------------
Depends: python-cairo, python-dateutil, python-gobject, python-matplotlib-data (>= [-0.99.3-1ubuntu3),-] {+0.99.3-1ubuntu2),+} python-numpy (>= 1:1.3.0), python-pyparsing, python-tz, python (<< 2.8), python (>= 2.6), python-support (>= 0.90.0), libatk1.0-0 (>= [-1.12.4),-] {+1.29.3),+} libc6 (>= 2.4), libcairo2 (>= 1.2.4), libfontconfig1 (>= 2.8.0), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libgdk-pixbuf2.0-0 (>= [-2.22.0),-] {+2.21.6),+} libglib2.0-0 (>= [-2.12.0),-] {+2.16.0),+} libgtk2.0-0 (>= 2.8.0), libpango1.0-0 (>= 1.14.0), libpng12-0 (>= 1.2.13-4), libstdc++6 (>= 4.4.0), {+tcl8.5 (>= 8.5.0), tk8.5 (>= 8.5.0),+} zlib1g (>= 1:1.1.4)
Installed-Size: [-7996-] {+8244+}
Version: [-0.99.3-1ubuntu3-] {+0.99.3-1ubuntu2+}

Revision history for this message
Julian Taylor (jtaylor) wrote :

build logs ubuntu3:
https://launchpadlibrarian.net/68241882/buildlog_ubuntu-natty-amd64.matplotlib_0.99.3-1ubuntu3_BUILDING.txt.gz
OPTIONAL BACKEND DEPENDENCIES
                libpng: 1.2.44
               Tkinter: no
                        * Using default library and include directories for
                        * Tcl and Tk because a Tk window failed to open.
                        * You may need to define DISPLAY for Tk to work so
                        * that setup can determine where your libraries are
                        * located. Tkinter present, but header files are not
                        * found. You may need to install development
                        * packages.

whereas ubuntu2:
https://launchpadlibrarian.net/58652824/buildlog_ubuntu-natty-amd64.matplotlib_tcl = Tkinter.Tcl()0.99.3-1ubuntu2_BUILDING.txt.gz
OPTIONAL BACKEND DEPENDENCIES
                libpng: 1.2.44
               Tkinter: Tkinter: 73770, Tk: 8.5, Tcl: 8.5

Changed in matplotlib (Ubuntu):
status: New → Confirmed
Revision history for this message
Julian Taylor (jtaylor) wrote :

adding a build dependency on tk-dev for tkConfig.sh solves the issue

Revision history for this message
Julian Taylor (jtaylor) wrote :

or adapt setupext to account for this change in tk8.5-dev

tk8.5 (8.5.9-2) unstable; urgency=low

  * Moved /usr/share/tcltk/tk8.5/tkConfig.sh back to the /usr/lib/tk8.5
    directory because it is architecture dependent.

Revision history for this message
WeatherGod (ben-v-root) wrote :

Because the default configuration uses the TKAgg backend, it might be a good idea to include 'matplotlib/backends/_tkagg.so' file in the list of files that must exist. I am not familiar with debian build files, but with rpm build packages, one can specify files that should exist after the build, and an error will be thrown if it doesn't exist. This way, such a mistake gets caught before commiting the package to the repos.

Revision history for this message
Peter Blyton (peterblyton) wrote :

A work around is to edit /etc/matplotlibrc and modify line 31 to a different backend, such as GTK or QT4.

Revision history for this message
Peter Blyton (peterblyton) wrote :

Correction on the previous comment, I found that GTK did not work, however GTKAgg did.

Revision history for this message
Manjul Apratim (manzdagratiano) wrote :

Many many thanks for this workaround! I hope the fix is released soon as well.

Changed in matplotlib (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → High
Changed in matplotlib (Ubuntu Natty):
status: Triaged → In Progress
assignee: nobody → Andres Rodriguez (andreserl)
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Julian,

Thank you for your patch. Looks good to me. I;'ll be uploading.

I also saw that you forwarded this patch upstream. Thank you for doing so.

Regards,

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package matplotlib - 0.99.3-1ubuntu4

---------------
matplotlib (0.99.3-1ubuntu4) natty; urgency=low

  * add patch 70_search_new_tkdir.patch
    + search in new path for tkConfig.sh, changed in tk 8.5.9-2 (LP: #752647)
 -- Julian Taylor <email address hidden> Thu, 07 Apr 2011 21:12:50 +0200

Changed in matplotlib (Ubuntu Natty):
status: In Progress → Fix Released
Revision history for this message
Manjul Apratim (manzdagratiano) wrote :

Thank you very very much for the fix!!! :)

Changed in matplotlib (Debian):
status: Unknown → Fix Released
Revision history for this message
lusepuster (thoeger) wrote :

Same problem seems to be back for upgrade to Precise. Should I file a new bug?

Revision history for this message
icb410 (ian-berke) wrote :

Seems to work for me... Here's the relevant portion from a python -v shell and import pylab:

import matplotlib.backends # directory /usr/lib/pymodules/python2.7/matplotlib/backends
# /usr/lib/pymodules/python2.7/matplotlib/backends/__init__.pyc matches /usr/lib/pymodules/python2.7/matplotlib/backends/__init__.py
import matplotlib.backends # precompiled from /usr/lib/pymodules/python2.7/matplotlib/backends/__init__.pyc
# /usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.pyc matches /usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py
import matplotlib.backends.backend_tkagg # precompiled from /usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.pyc
# /usr/lib/python2.7/lib-tk/Tkinter.pyc matches /usr/lib/python2.7/lib-tk/Tkinter.py
import Tkinter # precompiled from /usr/lib/python2.7/lib-tk/Tkinter.pyc
dlopen("/usr/lib/python2.7/lib-dynload/_tkinter.so", 2);
import _tkinter # dynamically loaded from /usr/lib/python2.7/lib-dynload/_tkinter.so
# /usr/lib/python2.7/lib-tk/Tkconstants.pyc matches /usr/lib/python2.7/lib-tk/Tkconstants.py
import Tkconstants # precompiled from /usr/lib/python2.7/lib-tk/Tkconstants.pyc
# /usr/lib/python2.7/lib-tk/FileDialog.pyc matches /usr/lib/python2.7/lib-tk/FileDialog.py
import FileDialog # precompiled from /usr/lib/python2.7/lib-tk/FileDialog.pyc
# /usr/lib/python2.7/lib-tk/Dialog.pyc matches /usr/lib/python2.7/lib-tk/Dialog.py
import Dialog # precompiled from /usr/lib/python2.7/lib-tk/Dialog.pyc
# /usr/lib/pymodules/python2.7/matplotlib/backends/tkagg.pyc matches /usr/lib/pymodules/python2.7/matplotlib/backends/tkagg.py
import matplotlib.backends.tkagg # precompiled from /usr/lib/pymodules/python2.7/matplotlib/backends/tkagg.pyc
dlopen("/usr/lib/pymodules/python2.7/matplotlib/backends/_tkagg.so", 2);
import matplotlib.backends._tkagg # dynamically loaded from /usr/lib/pymodules/python2.7/matplotlib/backends/_tkagg.so
# /usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.pyc matches /usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py
import matplotlib.backends.backend_agg # precompiled from /usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.pyc
dlopen("/usr/lib/pymodules/python2.7/matplotlib/backends/_backend_agg.so", 2);
import matplotlib.backends._backend_agg # dynamically loaded from /usr/lib/pymodules/python2.7/matplotlib/backends/_backend_agg.so
# /usr/lib/pymodules/python2.7/matplotlib/backends/windowing.pyc matches /usr/lib/pymodules/python2.7/matplotlib/backends/windowing.py
import matplotlib.backends.windowing # precompiled from /usr/lib/pymodules/python2.7/matplotlib/backends/windowing.pyc

Revision history for this message
Julian Taylor (jtaylor) wrote :

works fine here to using the TkAgg backend. _tkagg.so is also there so its a different issue.
please check if its not a local installation interfering and open a new bug with ubuntu-bug and add more information like the stack trace, the used backend, python -v -c "import pylab" output etc.

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.