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.

4
  • 1
    Try to use another back end: stackoverflow.com/a/37605654/2666859
    – Serenity
    Commented Apr 7, 2017 at 12:53
  • Thank you! It helped me! However, as I reed here: stackoverflow.com/questions/2801882/… You should change the backend before importind pyplot, otherwise it doesn't work. If you write an answer I can accept it :)
    – Gabrer
    Commented Apr 7, 2017 at 13:38
  • 1
    Possible duplicate of How can I set the 'backend' in matplotlib in Python?
    – pingul
    Commented Apr 7, 2017 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
    Commented Apr 7, 2017 at 15:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.