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

NiceGUI启动报错:'int' object has no attribute 'items'求助

解决NiceGUI启动报错:'int' object has no attribute 'items'

核心原因与修复方案

1. 升级Python版本

NiceGUI的新版对Python 3.9兼容性不足,其依赖的Starlette、Anyio等异步库已不再适配Python 3.9的部分特性。建议将Python升级至3.10或更高版本,这是最彻底的解决方式。

2. 锁定兼容的依赖版本

如果无法升级Python,可安装适配Python 3.9的特定版本依赖:

  • 先卸载现有相关依赖:
pip uninstall -y nicegui starlette anyio
  • 安装指定兼容版本:
pip install nicegui==1.3.7 starlette==0.27.0 anyio==3.7.1

3. 确认虚拟环境状态

确保你始终在激活的虚拟环境中操作,避免系统全局Python环境的依赖干扰。重新运行测试代码:

from nicegui import ui
ui.label('Hello NiceGUI!')
ui.run()

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 07:55:10