Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Inheritance a class from URL is forbidden

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
like image 832
Jeriel Fernandez Avatar asked May 03 '18 23:05

Jeriel Fernandez


2 Answers

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.

like image 67
Taku Avatar answered Oct 21 '22 05:10

Taku


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

yarl<1.2

like image 1
Lenny the burger Avatar answered Oct 21 '22 07:10

Lenny the burger