I get the following error while importing Tkinter:
Python 2.7.1 (r271:86832, Jun 11 2011, 11:34:27)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkin开发者_C百科ter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>>
What shall I do?
Probably just install Tkinter - maybe apt-get install python-tk
will do it if you have a Debian based distribution. Might be python3-tk
or something else for other distributions.
You can try doing instead
from tkinter import *
I dont know why but this seems to work foor me it just means from tkinter import all. another thing they changed it in python 3.5 to a lower case t. just for future knowledge.
精彩评论