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

运行自制Discord机器人遇TypeError:禁止从URL类继承,求解决方法

Hey there, let's tackle this Discord bot import error you're facing. From the partial traceback you shared, it looks like the issue pops up when importing the discord module, specifically when trying to load the client components. Here are some actionable fixes to try out:

1. Fix Python Version Compatibility

Discord.py (the library powering your bot) dropped support for Python 3.6 a while ago—this is almost certainly a key issue here. You have two options:

  • Upgrade Python: Move to at least Python 3.8 (the minimum supported version for recent discord.py releases). After upgrading, confirm your version with python --version to ensure it's properly set up.
  • Use a Legacy Discord.py Version: If you can't upgrade Python, install the last discord.py release that supports 3.6 with this command:
    pip install discord.py==1.7.3
    
2. Reinstall Discord.py to Fix Corrupted Files

Partial downloads or corrupted installations often cause import failures. Follow these steps:

  • Uninstall the existing module first:
    pip uninstall discord.py
    
  • Clear cached packages to avoid leftover issues:
    pip cache purge
    
  • Reinstall the module (use the legacy version for Python 3.6, or the latest version if you upgraded Python):
    # For Python 3.6
    pip install discord.py==1.7.3
    # For newer Python versions
    pip install discord.py
    
3. Verify Your Virtual Environment (If Using One)

If you're working in a virtual environment, it's easy to accidentally install packages in your global Python instead of the venv. Fix this by:

  • Activating your venv (Windows example):
    .\venv\Scripts\activate
    
  • Reinstalling discord.py while the venv is active, using the command matching your Python version.
4. Update Critical Dependencies

Discord.py relies on aiohttp and websockets for network communication. Outdated versions of these can break imports. Update them with:

pip install -U aiohttp websockets

Give these steps a try one by one—most likely the Python version or corrupted installation is the root cause.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 10:52:39