TypeError: Inheritance a class from URL is forbidden

陌路散爱 提交于 2019-12-08 18:53:36

问题


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:\Users\Jeriel\Desktop\JerryBot\run.py", line 1, in <module>
    import discord
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\__
init__.py", line 20, in <module>
    from .client import Client, AppInfo
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\cl
ient.py", line 30, in <module>
    from .guild import Guild
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\gu
ild.py", line 39, in <module>
    from .channel import *
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\ch
annel.py", line 31, in <module>
    from .webhook import Webhook
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\we
bhook.py", line 27, in <module>
    import aiohttp
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\__
init__.py", line 6, in <module>
    from .client import *  # noqa
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\cl
ient.py", line 15, in <module>
    from . import connector as connector_mod
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\co
nnector.py", line 17, in <module>
    from .client_proto import ResponseHandler
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\cl
ient_proto.py", line 6, in <module>
    from .http import HttpResponseParser, StreamWriter
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\ht
tp.py", line 8, in <module>
    from .http_parser import (HttpParser, HttpRequestParser, HttpResponseParser,

  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\ht
tp_parser.py", line 15, in <module>
    from .http_writer import HttpVersion, HttpVersion10
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\aiohttp\ht
tp_writer.py", line 304, in <module>
    class URL(yarl.URL):
  File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\yarl\__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

回答1:


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.

You need to run the following:

pip install "yarl<1.2"

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.




回答2:


I ran into the same problem but for setting up self-bot, for that just paste this into requirments.txt:

yarl<1.2




回答3:


This answer is for aiohttp. If somebody gets to this problem using aiohttp 2.2.5, it can be fixed using the 0.13.0 version of yarl. By example just:

pip install yarl==0.13.0


来源:https://stackoverflow.com/questions/50165167/typeerror-inheritance-a-class-from-url-is-forbidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!