我正在尝试使我的第一个齿轮工作,但每次尝试运行该程序时,都会出现此错误:
Traceback (most recent call last):
File "D:\Sebi\Desktop\Servant (Discord Bot)\bot file.py", line 1, in <module>
import discord
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 28, in <module>
from .user import User
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\user.py", line 27, in <module>
from .utils import snowflake_time
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\utils.py", line 31, in <module>
import asyncio
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\asyncio\__init__.py", line 21, in <module>
from .base_events import *
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 17, in <module>
import concurrent.futures
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\__init__.py", line 17, in <module>
from concurrent.futures.process import ProcessPoolExecutor
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\process.py", line 55, in <module>
from multiprocessing.connection import wait
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\multiprocessing\connection.py", line 18, in <module>
import tempfile
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
File "D:\Sebi\Desktop\Servant (Discord Bot)\random.py", line 1, in <module>
from discord.ext import commands
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\__init__.py", line 13, in <module>
from .bot import Bot, when_mentioned, when_mentioned_or
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 35, in <module>
from .core import GroupMixin, Command, command
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 35, in <module>
from . import converter as converters
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\converter.py", line 164, in <module>
class InviteConverter(Converter):
File "C:\Users\Sebi\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\converter.py", line 165, in InviteConverter
@asyncio.coroutine
AttributeError: module 'asyncio' has no attribute 'coroutine'
我在其他问题上读到,这通常可以通过升级到python 3.5(它已经打开)并清除py缓存来解决。它仍然给我同样的错误。 这是我的齿轮代码:
from discord.ext import commands class Public(object): def __init__(self,client): self.client = client @commands.command() async def ping(self,ctx): await ctx.send("Pong") def setup(client): client.add_cog(Public(client))