简体   繁体   English

Tkinter导入语法错误Python

[英]Tkinter Import Syntax Error Python

I am getting an error whenever I try to import the tkinter module. 每当我尝试导入tkinter模块时,我都会收到错误消息。 I'm using Python 3.4 so the capital T isn't an issue. 我正在使用Python 3.4,因此大写字母T不是问题。

from tkinter import *

root = Tk()

root.mainloop()

It throws back an error like: 它抛出类似以下的错误:

Traceback (most recent call last):
  File "<string>", line 420, in run_nodebug
  File "<module1>", line 11, in <module>
  File "C:\Python34\lib\tkinter\__init__.py", line 3372
  t        self.tk.call(('image', 'create', imgtype, name,) + options)
            ^
SyntaxError: invalid syntax

Thanks for the help! 谢谢您的帮助!

The problem seems to be somehow existing in the init file itself. 这个问题似乎在init文件本身中已经存在。 Just go to the file in your pc. 只需转到您PC中的文件即可。

C:\Python34\lib\tkinter\__init__.py

Edit that init .py with Idle or whatever IDE you use. 使用Idle或您使用的任何IDE编辑该init .py。 Next go to the line number 3372 and remove that unwanted character 't' from the line 接下来转到行号3372并从行中删除该不需要的字符't'

 t        self.tk.call(('image', 'create', imgtype, name,) + options)

It'll do the work for you. 它将为您完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM