导入discord.py时出现TypeError

时间:2018-05-09 18:20:33

标签: python discord discord.py discord.py-rewrite

我刚安装了discord.py重写分支,但尝试使用import discordfrom discord.ext import commands只会导致TypeError。

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 +上运行有任何不同

2 个答案:

答案 0 :(得分:0)

您的aiohttp包可能已过期。

尝试

pip install --upgrade aiohttp

答案 1 :(得分:0)

我试图在我的python 3.7上安装discord.py,但它不起作用。

我必须安装python 3.6.6才能运行,也许您正在使用python 3.7,如果是这样,则应尝试回滚到python 3.6.6