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

为何导入customtkinter后出现AttributeError: 模块无CTkFont属性?

问题解答:AttributeError: module 'customtkinter' has no attribute 'CTkFont'
  • 错误原因:你使用的customtkinter版本过低,CTkFont是customtkinter v5.0及以后版本才新增的API,旧版本中没有这个属性,因此触发该错误。

  • 解决办法:

    1. 升级customtkinter到最新版本,执行命令:pip install --upgrade customtkinter
    2. 若暂时不想升级,可直接用字体参数元组替代CTkFont,修改后的代码如下:
      label1 = customtkinter.CTkLabel(master=frame, text="WUA", font=("Verdana", 45))
      label1.pack(pady=20, padx=20)
      
  • 是否需要单独导入:不需要单独导入CTkFont,只要版本符合要求,直接通过customtkinter.CTkFont调用即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 17:20:41