简体   繁体   English

在Mac中使用终端运行文件时,为什么Tkinter无法在python上正常工作

[英]Why tkinter not working properly for python when file run with terminal in mac

I'm using tkinter to build gui with my mac.normally I'm using python IDLE to run and test the code. 我使用tkinter建立gui与我mac.normally我使用python的IDLE运行和测试代码。 I created a new file with .py extension and run it. 我创建了一个扩展名为.py的新文件并运行它。 it works properly. 它工作正常。 this is the code. 这是代码。

from tkinter import *

mywin  = Tk();
mywin.title("window for mac")

This works fine 这很好

Then I tried to run the file using terminal and tried to launch the file with python launcher.at that time it gives following error 然后我尝试使用terminal运行文件并尝试使用python launcher启动文件。当时它给出以下错误

  File "check.py", line 1, in <module>
    from tkinter import *
    ImportError: No module named tkinter

my python version is Python 2.7.10 . 我的python版本是Python 2.7.10 some says it is corruption on python. 有人说这是python上的损坏。 I tried to install python with home-brew also.but didn't get any result. 我也尝试用自制软件安装python。但是没有得到任何结果。

Idle and Terminal python version are different ! 空闲和终端python版本不同! Need using same version of Python. 需要使用相同版本的Python。

No module named tkinter is python2.X error ! 没有名为tkinter的模块是python2.X错误! No module named Tkinter is python3.X error. 没有名为Tkinter的模块出现python3.X错误。

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

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