python - 似乎无法为 python 导入 Tkinter

标签 python python-2.7 tkinter

您好,感谢您查看此内容,

当我尝试导入 tkinter 时,它显示 Unresolved 导入

导入错误:没有名为 tkinter 的模块

我最初安装python时出现了某种错误

以下是路径:

输出:

/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-     scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/Users/wes/Desktop/UM/Python/guiTest
/Users/wes/Desktop/UM/Python/guiTest/testgui

谢谢 -韦斯

最佳答案

您正在使用小写 T 导入 tkinter。您在评论中发布的代码适用于 Python 3.X,如果您也有该版本,则导入语句是正确的,但由于您正在使用Python 2.7 中,模块的名称为 TkintertkMessageBox(而不是 tkintertkinter.messagebox)。

关于python - 似乎无法为 python 导入 Tkinter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16617383/

相关文章:

python - 保存在 Models.py 之前对 ManyToManyField 进行验证

python - 如何在 Google App Engine 中动态更改 python 应用程序的日志记录级别?

python - 数据框中两列的 Pandas diff() 功能

Python。返回当前光标位置和最后一次鼠标左键单击的位置

Python - 使用 Pytesseract 读取图像中的数字

python - golang <--> python 通信的最简单的 pub-sub 通信,可能跨机器?

python - 如何提示用户将他们的 Google 帐户与我的应用程序连接?

python - 在 tkinter 中获取光标的绝对位置

python - 从csv输出python中删除所有逗号分隔

python - 列表中连续零的计数