You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用customtkinter创建界面时出现AttributeError:无CTk属性问题求助

解决AttributeError: module 'customtkinter' has no attribute 'CTk'的问题

原因分析

你遇到的问题是因为customtkinter版本过低,CTk是customtkinter 4.0及以上版本才引入的新根窗口类,旧版本中对应的根窗口类为CTkTk。

解决方法

方法1:升级customtkinter到最新版本

打开终端/命令提示符,执行以下命令:

pip install --upgrade customtkinter

升级完成后,你的原有代码即可正常运行,弹出一个空白的customtkinter窗口。

方法2:适配旧版本代码(不推荐,建议优先升级)

如果暂时无法升级版本,可以将代码中的CTk替换为旧版本的CTkTk:

import customtkinter
app = customtkinter.CTkTk()
app.mainloop()

验证

完成上述操作后,运行脚本就能正常显示一个简单的customtkinter界面。

内容的提问来源于stack exchange,提问作者Najiib Rashiid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 01:56:59