3

I tried to import matplotlib.pyplot, however received an error relating to python-tk not being installed. It appears to be installed but I still appear to be receiving the error. Any help would be appricated. For further info, the output is below. Many thanks.

    $ ipython
    Python 2.7.7 (default, Jun  3 2014, 16:16:56)
    Type "copyright", "credits" or "license" for more information.

    IPython 2.1.0 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.

    In [1]: import numpy as np

    In [2]: import matplotlib.pyplot as plt
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-2-eff513f636fd> in <module>()
    ----> 1 import matplotlib.pyplot as plt

    /usr/lib/pymodules/python2.7/matplotlib/pyplot.py in <module>()
         96
         97 from matplotlib.backends import pylab_setup
    ---> 98 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
         99
        100

    /usr/lib/pymodules/python2.7/matplotlib/backends/__init__.pyc in pylab_setup()
         26     # imports. 0 means only perform absolute imports.
         27     backend_mod = __import__(backend_name,
    ---> 28                              globals(),locals(),[backend_name],0)
         29
         30     # Things we pull in from all backends

    /usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py in <module>()
          6 import os.path
          7
    ----> 8 import Tkinter as Tk, FileDialog
          9
         10 # Paint image to Tk photo blitter extension

    /usr/lib/python2.7/lib-tk/Tkinter.py in <module>()
         40     import _tkinter
         41 except ImportError, msg:
    ---> 42     raise ImportError, str(msg) + ', please install the python-tk package'
         43 tkinter = _tkinter # b/w compat for export
         44 TclError = _tkinter.TclError

    ImportError: libBLT.2.4.so.8.5: cannot open shared object file: No such file or directory, please install the python-tk package
jmood
  • 77
  • 2
  • 9

3 Answers3

5

No such file or directory, please install the python-tk package

Install the package using:

sudo apt-get install python-tk
Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321
  • Thanks for the reply. It appears to be installed. Double checked and got: apt-get install python-tk Reading package lists... Done Building dependency tree Reading state information... Done python-tk is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. – jmood Jun 16 '14 at 12:18
  • what distribution are you using? Do you have `libBLT.2.4.so.8.5` in usr/lib? – Padraic Cunningham Jun 16 '14 at 12:33
  • try `sudo apt-get install blt` – Padraic Cunningham Jun 16 '14 at 12:53
  • how about `sudo apt-get build-dep matplotlib` – jrsm Jun 16 '14 at 13:55
  • blt appears to be installed and the library is there: $ ls /usr/lib/ | grep libBLT libBLT.2.4.so.8.6 libBLTlite.2.4.so.8.6 tried installing the dependencies but to no avail. Using Linux machine 3.14-1-amd64 #1 SMP Debian 3.14.4-1 (2014-05-13) x86_64 GNU/Linux $ – jmood Jun 16 '14 at 15:22
  • Also the version you get from `dpkg -s blt` – Padraic Cunningham Jun 16 '14 at 16:00
  • The variable is empty and the dpkg output can be found here: http://pastebin.com/NiMYHxmr Thanks again – jmood Jun 17 '14 at 10:14
  • I am using `2.4z-7` you are using `2.4z-9` try downgrading to `2.4z-7` https://launchpad.net/ubuntu/+source/blt/2.4z-7 there is a know issue using 2.4z-9` – Padraic Cunningham Jun 17 '14 at 10:27
3

As a temporary arrangement just do

mv libBLT.2.4.so.8.6 libBLT.2.4.so.8.5

under /usr/lib/ . It should work fine again

Rovyer
  • 31
  • 1
  • Thanks, have that a shot but didn't have much luck (http://pastebin.com/raw.php?i=jfTe19qJ). I've spotted http://stackoverflow.com/questions/12948446/matplotlib-wont-draw-python3 so I'm going through that at the moment. – jmood Jun 17 '14 at 21:06
  • Given that this answer has helped at least one user, it would be good to add an explanation. – Jamie Bull Feb 16 '16 at 11:16
1

See debian bugreport: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751767 (as far as I know, matplotlib does not depend on "blt")