导入时出现类型错误 discord.py
TypeError from importing discord.py
我刚刚安装了 discord.py 重写分支,但尝试使用 import discord
或 from discord.ext import commands
只会导致类型错误。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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
虽然错误在技术上是来自 yarl 而不是来自 discord.py 本身,但错误仅在尝试导入模块时发生。
我已经尝试重新安装 python 以及 discord.py 重写分支,如果它有任何不同,我 运行 在 RPi 3 B+
您的 aiohttp 包可能已过时。
尝试
pip install --upgrade aiohttp
我试图在我的 python 3.7 上安装 discord.py 但没有成功。
我必须安装 python 3.6.6 才能运行,也许您正在使用 python 3.7,如果是这样,您应该尝试回滚到 python 3.6.6
我刚刚安装了 discord.py 重写分支,但尝试使用 import discord
或 from discord.ext import commands
只会导致类型错误。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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
虽然错误在技术上是来自 yarl 而不是来自 discord.py 本身,但错误仅在尝试导入模块时发生。
我已经尝试重新安装 python 以及 discord.py 重写分支,如果它有任何不同,我 运行 在 RPi 3 B+
您的 aiohttp 包可能已过时。
尝试
pip install --upgrade aiohttp
我试图在我的 python 3.7 上安装 discord.py 但没有成功。
我必须安装 python 3.6.6 才能运行,也许您正在使用 python 3.7,如果是这样,您应该尝试回滚到 python 3.6.6