4

I am using Ubuntu 16.04 and Python 2.7, and I have set up a virtual environment (virtualenv) using a pypy interpreter. I even installed succeffully the matplotlib library.

However, we it comes to using it on my own code I get this error messagge:

Traceback (most recent call last):
File "my_script.py", line 20, in import matplotlib.pyplot as plt
File "/home/.../venv/site-packages/matplotlib/pyplot.py", line 115, in _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/.../venv/site-packages/matplotlib/backends/init.py", line 32, in pylab_setup globals(),locals(),[backend_name],0)
File "/home/.../venv/site-packages/matplotlib/backends/backend_tkagg.py", line 13, in import matplotlib.backends.tkagg as tkagg
File "/home/.../venv/site-packages/matplotlib/backends/tkagg.py", line 9, in from matplotlib.backends import _tkagg RuntimeError: Cannot dlopen tkinter module file

What can I do to fix it?

EDIT: The solution proposed here is the same, but I think that the problem (pypy and matplotlib) and the error message are quite different.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Gabrer
  • 465
  • 5
  • 21
  • 1
    Try to use another back end: http://stackoverflow.com/a/37605654/2666859 – Serenity Apr 07 '17 at 12:53
  • Thank you! It helped me! However, as I reed here: http://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined You should change the backend before importind pyplot, otherwise it doesn't work. If you write an answer I can accept it :) – Gabrer Apr 07 '17 at 13:38
  • 1
    Possible duplicate of [How can I set the 'backend' in matplotlib in Python?](http://stackoverflow.com/questions/4930524/how-can-i-set-the-backend-in-matplotlib-in-python) – pingul Apr 07 '17 at 13:50
  • @pingul You are right if you mean that the solution is the same, but I think that the problem (pypy and matplotlib) and the error message are quite different; as many people search in Google just typing their problems, I think that also this question could be useful :) – Gabrer Apr 07 '17 at 15:02

0 Answers0