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

Python中导入discord.ui及discord模块启动报错求助(PyCharm环境)

解决discord.ui与discord.py导入冲突问题
  • 核心原因:discord.ui 是 discord.py 官方库的内置模块,无需单独安装。单独安装第三方的 discord.ui 包会和官方 discord.py 产生命名空间冲突,导致启动报错。

  • 修复步骤:

    1. 卸载第三方 discord.ui 包:
      python3 -m pip uninstall discord.ui
      
    2. 更新 discord.py 到最新版本,避免版本兼容问题:
      python3 -m pip install --upgrade discord.py
      
    3. 保持导入代码不变即可(因为 discord.py 内置了 discord.ui):
      import discord
      from discord.ui import View, Button
      
  • 验证操作:重启PyCharm或刷新项目依赖后重新运行程序,报错即可消除。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 03:01:01