Quantcast

ImportError: cannot import name '_tkagg'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ImportError: cannot import name '_tkagg'

jcb0026
This post has NOT been accepted by the mailing list yet.
Greetings,
I'm trying to run a Python script that uses tkinter to create a GUI and matplotlib to display a graph onto the GUI. Our System Administrators installed Python 3.5, tkinter, and matplotlib onto a Redhat Linux 7.2 machine. Within the code of our script, to import all necessary matplotlib functions and modules, we call:

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import matplotlib
matplotlib.use('TkAgg')

However, when the script is ran, this is the result:

  File "ourScript.py", line 17, in <module>
    from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
  File "/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 11, in <module>
    import matplotlib.backends.tkagg as tkagg
  File "/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/matplotlib/backends/tkagg.py", line 2, in <module>
    from matplotlib.backends import _tkagg
ImportError: cannot import name '_tkagg'

After doing some research, it seems that this could be due to matplotlib being installed before tkinter. Is this likely the case?

Thanks,
James






Loading...