I think that the aiohttp dependency version is broken in rewrite.
The following Dockerfile produces the following traceback when the container is run (src/app.py simply import discord):
FROM python:3.6-alpine3.7
RUN wget 'https://github.com/Rapptz/discord.py/archive/rewrite.tar.gz' -O /tmp/discord.py.tar.gz
RUN pip install /tmp/discord.py.tar.gz
#RUN pip install --upgrade aiohttp
COPY src src
CMD python /src/app.py
Traceback (most recent call last):
File "/src/app.py", line 1, in <module>
import discord
File "/usr/local/lib/python3.6/site-packages/discord/__init__.py", line 20, in <module>
from .client import Client, AppInfo
File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 30, in <module>
from .guild import Guild
File "/usr/local/lib/python3.6/site-packages/discord/guild.py", line 39, in <module>
from .channel import *
File "/usr/local/lib/python3.6/site-packages/discord/channel.py", line 31, in <module>
from .webhook import Webhook
File "/usr/local/lib/python3.6/site-packages/discord/webhook.py", line 27, in <module>
import aiohttp
File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import * # noqa
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 15, in <module>
from . import connector as connector_mod
File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 17, in <module>
from .client_proto import ResponseHandler
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_proto.py", line 6, in <module>
from .http import HttpResponseParser, StreamWriter
File "/usr/local/lib/python3.6/site-packages/aiohttp/http.py", line 8, in <module>
from .http_parser import (HttpParser, HttpRequestParser, HttpResponseParser,
File "/usr/local/lib/python3.6/site-packages/aiohttp/http_parser.py", line 15, in <module>
from .http_writer import HttpVersion, HttpVersion10
File "/usr/local/lib/python3.6/site-packages/aiohttp/http_writer.py", line 304, in <module>
class URL(yarl.URL):
File "/usr/local/lib/python3.6/site-packages/yarl/__init__.py", line 232, in __init_subclass__
"is forbidden".format(cls))
TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is forbidden
Upgrading aiohttp after the install to the most recent version resolves the issue, but the build warns that discord-py 1.0.0a0 has requirement aiohttp<2.3.0,>=2.0.0, but you'll have aiohttp 3.2.1 which is incompatible.
Getting this error?
TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is forbidden
This is due to yarl 1.2 having a breaking change that breaks aiohttp. Downgrade your yarl using pip install -U "yarl<1.2"
In relation to fourjr's answer above, it may be necessary to downgrade even further pip install "yarl<1" otherwise you'll encounter a different error.
It may also be worth noting that you can reinstall aiohttp to the most recent version with zero issues instead.
Been running three bots on rewrite for the past month and have yet to come across a problem with this.
Fixed by bumping.
Most helpful comment
Getting this error?
This is due to yarl 1.2 having a breaking change that breaks aiohttp. Downgrade your yarl using
pip install -U "yarl<1.2"