【发布时间】:2017-10-19 10:32:25
【问题描述】:
我有一个小问题,我的 Discord 机器人是用 Python 编写的,但我不断收到错误消息。这是我的机器人的代码:
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
if message.content.startswith('!test'):
await client.send_message(message.channel, 'Calculating messages...')
client.run('You arent gonna get my token =D')
当我运行它时,这个错误来了:
Traceback (most recent call last):
File "C:\Users\DELL\Documents\Testing\discordbt.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
我真的不知道该怎么办,我所做的只是在CMD中执行以下命令:
pip install discord.py
pip install asyncio
就是这样,我确保安装的模块没有错误,他们确实做到了,一切都已启动,我知道您需要一些其他“程序”,我已经安装了以下程序:Python 3.6.3 64x 和 Python 3.7.0a2 64x
我的电脑是 64x 位架构,所以完全匹配。
【问题讨论】:
-
您确定为您的脚本使用了正确的解释器吗?当您安装了多个 Python dist 时,很常见会看到“ModuleNotFound”。
-
翻译者?区?向我解释:) @lotrus28
-
@DeadlyFirex Interpreter 是一个运行脚本的程序。 Dist 是一个发行版——一个与包配对的解释器。每个发行版都有自己的安装文件夹,您可以在一台计算机上拥有多个 dist。例如,您可以同时安装 Python2、Python3 和 Anaconda。每个都有自己的包添加过程。例如。
pip只会将一个包添加到 P2,pip3-- 到 P3。如果你使用pip安装包,但在你的项目中使用P3解释器,你应该切换到P2或使用pip3将包添加到P3文件夹。 -
已经修好了,谢谢!
标签: python pip bots python-asyncio discord.py