TypeError:禁止从 URL 继承类

TypeError: Inheritance a class from URL is forbidden(TypeError:禁止从 URL 继承类)
本文介绍了TypeError:禁止从 URL 继承类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在尝试运行我为 Discord 制作的机器人时遇到了这个错误.这发生在下载一些模块后.有没有办法解决这个问题?

I run into this error when trying to run a bot I made for Discord. This occurred after downloading some modules. Is there any way to fix this?

Traceback (most recent call last):
  File "C:UsersJerielDesktopJerryBot
un.py", line 1, in <module>
    import discord
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesdiscord\__
init__.py", line 20, in <module>
    from .client import Client, AppInfo
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesdiscordcl
ient.py", line 30, in <module>
    from .guild import Guild
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesdiscordgu
ild.py", line 39, in <module>
    from .channel import *
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesdiscordch
annel.py", line 31, in <module>
    from .webhook import Webhook
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesdiscordwe
bhook.py", line 27, in <module>
    import aiohttp
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttp\__
init__.py", line 6, in <module>
    from .client import *  # noqa
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttpcl
ient.py", line 15, in <module>
    from . import connector as connector_mod
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttpco
nnector.py", line 17, in <module>
    from .client_proto import ResponseHandler
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttpcl
ient_proto.py", line 6, in <module>
    from .http import HttpResponseParser, StreamWriter
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttpht
tp.py", line 8, in <module>
    from .http_parser import (HttpParser, HttpRequestParser, HttpResponseParser,

  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttpht
tp_parser.py", line 15, in <module>
    from .http_writer import HttpVersion, HttpVersion10
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesaiohttpht
tp_writer.py", line 304, in <module>
    class URL(yarl.URL):
  File "C:UsersJerielAppDataRoamingPythonPython36site-packagesyarl\__ini
t__.py", line 230, in __init_subclass__
    "is forbidden".format(cls))
TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is for
bidden

推荐答案

Discord.py rewrite 分支最近在 requirements.txt 和 aiohttp 支持上出现了一些问题.需要手动安装低版本的 yarl 来支持 discord.py 所需的 aiohttp 库.

Discord.py rewrite branch has some problems recently with its requirements.txt and aiohttp support. You need to manually install a lower version of yarl to support discord.py's required aiohttp library.

您需要运行以下命令:

pip install "yarl<1.2"

<小时>

更新

新版本的 discord.py rewrite 修复了这个问题,您不再需要按照上述解决方案进行操作.正确的做法是从 GitHub 重新下载 discord.py rewrite 并升级包.


UPDATE

The new versions of discord.py rewrite fixed this problem, you no longer need to do follow the aforementioned solution. The correct action to take is to re-download discord.py rewrite from GitHub and upgrade the packages.

这篇关于TypeError:禁止从 URL 继承类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)