Reputation: 13
I encountered this error when trying to import Tkinter
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Tkinter.py", line 3, in <module>
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 7, in <module>
from six.moves import tkinter_filedialog as FileDialog
File "C:\Python27\lib\site-packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python27\lib\site-packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python27\lib\site-packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Python27\lib\lib-tk\FileDialog.py", line 12, in <module>
from Dialog import Dialog
File "C:\Python27\lib\lib-tk\Dialog.py", line 4, in <module>
from Tkinter import _cnfmerge
ImportError: cannot import name _cnfmerge
I am not sure what is going on here, but I think it might have to do with numpy.
Upvotes: 1
Views: 1125
Reputation: 321
I am building an application in python3+tkinter and had the same problem. I replaced 'NavigationToolbar2TkAgg' with 'NavigationToolbar2Tk' and it compiled successfully. Try replacing it and see if it works for you.
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
Upvotes: 0
Reputation: 9597
File "Tkinter.py", line 3, in <module>
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
The real Tkinter.py certainly does not contain any references to matplotlib. You have another file with the same name on Python's search path, which is shadowing the real module.
Upvotes: 1