PIP 安装期间 Python3.x 中的“'Module "Discord" not found'”
''Module "Discord" not found'' in Python3.x during PIP installation
我有一个小问题,我的 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
就是这样,我确保模块安装没有错误,他们确实做到了,一切正常,我知道你需要一些其他的 "programs" 我已经安装了以下程序:Python 3.6.3 64x
和 Python 3.7.0a2 64x
我的 PC 来自 64x 位架构,因此完全匹配。
pip 可能正在将外部目录中的模块安装到您 运行 脚本所使用的 python 版本。尝试通过将版本号附加到终端命令来指定 python 版本,例如 python3.6 -m pip install discord.py
。如果这不起作用,请尝试使用 pip3
而不是 pip
.
编辑:也不要尝试安装 asyncio
,它是标准库的一部分。
我有一个小问题,我的 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
就是这样,我确保模块安装没有错误,他们确实做到了,一切正常,我知道你需要一些其他的 "programs" 我已经安装了以下程序:Python 3.6.3 64x
和 Python 3.7.0a2 64x
我的 PC 来自 64x 位架构,因此完全匹配。
pip 可能正在将外部目录中的模块安装到您 运行 脚本所使用的 python 版本。尝试通过将版本号附加到终端命令来指定 python 版本,例如 python3.6 -m pip install discord.py
。如果这不起作用,请尝试使用 pip3
而不是 pip
.
编辑:也不要尝试安装 asyncio
,它是标准库的一部分。