我对python相当陌生,对制作不和谐脚本感兴趣。安装完所有应用程序并插入示例代码后,出现错误。Python 3,ImportError:无法导入名称'HTTPClient'
import discord
import asyncio
client = discord.Client()
async def my_background_task():
await client.wait_until_ready()
counter = 0
channel = discord.Object(id='channel_id_here')
while not client.is_closed:
counter += 1
await client.send_message(channel, counter)
await asyncio.sleep(60) # task runs every 60 seconds
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.loop.create_task(my_background_task())
client.run('token')
错误:
F:\Python\python.exe "F:/Python Projects/DiscordPlugin1.py"
Traceback (most recent call last):
File "F:/Python Projects/DiscordPlugin1.py", line 1, in <module>
import discord
File "F:\Python\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "F:\Python\lib\site-packages\discord\client.py", line 45, in <module>
from .http import HTTPClient
ImportError: cannot import name 'HTTPClient'
Process finished with exit code 1
如果任何人都可以至少指向我在这将是非常赞赏的正确方向。
你确定你用python3执行它吗? 'python --version' –
是的,运行后检查cmd说我正在运行Python 3.5.2。 –
也有一些信息可能有所帮助,discord.py(https://github.com/Rapptz/discord.py)的github页面说使用'python3 -m pip install -U discord.py'但是,python3不是被认为是一个命令,所以我使用'python -m pip install -U discord.py'来安装它。 –