1

On Ubuntu 16.04 I have a virtualenv (15.0.2). I did install matplotlib 1.5.3 and I get this error:

import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libBLT.2.4.so.8.6: cannot open shared object file: No such file or directory

Thanks

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • I have notice this question earlier, but it doesn't mention virtualenv. – Daniela Scarpa Oct 22 '16 at 11:46
  • 2
    I have solved this issue thanks to this http://stackoverflow.com/questions/29433824/unable-to-import-matplotlib-pyplot-as-plt-in-virtualenv/33447513 typing commands "pip uninstall matplotlib" and "pip install matplotlib==1.4.3" on my virtualenv. – Daniela Scarpa Oct 22 '16 at 14:23

1 Answers1

2

I'm presuming you are using python3.

First of all, type help('modules') in your python shell. This should return all modules that are currently installed. If tkinter is not listed there, try the following:

import sysconfig
print(sysconfig.get_paths())

This will print out all the paths in which python is looking modules. Move your tkinter module to one of the folders listed above (it should usually be site-packages but that might depend on your python set-up.

If that still doesn't solve the issue, try

sudo apt-get install python python-tk idle python-pmw python-imaging

If you are using ubuntu, python libraries should include tkinter. Hence the code above is re-installing python.

Hope I could help, Narusan

Narusan
  • 482
  • 1
  • 5
  • 18
  • Sorry, missing data, I am using python 2.7.9. I did try to install matplotlib in standard python installation (/usr/bin/..) and it works perfectly, so I suppose I have all the libraries. The problem comes out when I run the code with my virtualenv interpreter. In this case, there's something wrong with tk, which is not installable on virtualenv using commands: – Daniela Scarpa Oct 22 '16 at 11:04
  • cd .../path/to/env , source/bin/activate , pip install tk – Daniela Scarpa Oct 22 '16 at 11:05
  • Seems that the command "sudo apt-get install python python-tk idle python-pmw python-imaging" did solve my issue. Sorry I cannot +1 your answer. Thanks a lot!!!! – Daniela Scarpa Oct 22 '16 at 11:33
  • Sorry, it didn't solve. I still have this problem. It does work on my standard python but it doesn't on virtualenv.. – Daniela Scarpa Oct 22 '16 at 11:43
  • Glad that you could solve it. Wish you the best of luck with it! – Narusan Oct 24 '16 at 15:30