简体   繁体   English

Tkinter在有思想的顶篷上(Windows)

[英]tkinter on enthought canopy (Windows)

tkinter is supposed to be installed with standard python, but on my windows 8.1 computer (using enthought Canopy), I get the following error. tkinter应该与标准python一起安装,但是在我的Windows 8.1计算机(使用有思想的Canopy)上,出现以下错误。 I just updated everything. 我刚刚更新了所有内容。

import tkinter
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-b98d59735c04> in <module>()
----> 1 import tkinter

ImportError: No module named tkinter

I am going to make my comment into an answer for any future readers. 我将对以后的读者发表自己的评论。

You are using Python 2.x. 您正在使用Python2.x。 In this version, the Tkinter library is named Tkinter , not tkinter . 在此版本中,Tkinter库名为Tkinter ,而不是tkinter The lowercase tkinter is Python 3.x's name for the library. 小写的tkinter是该库的Python 3.x名称。

Simply replace your import line with: 只需将您的导入行替换为:

import Tkinter

and the problem will be solved. 问题就会解决。

Keep in mind though that this is the Python 2.x library, so some 3.x features will not be available. 请记住,尽管这是Python 2.x库,所以某些3.x功能将不可用。

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

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