开发者

error while importing Tkinter in python [duplicate]

开发者 https://www.devze.com 2023-04-04 06:05 出处:网络
This question already has answers here: Install tkinter for Python [duplicate] (25 answers) Closed 7 years ago.
This question already has answers here: Install tkinter for Python [duplicate] (25 answers) Closed 7 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消