【问题标题】:''Module "Discord" not found'' in Python3.x during PIP installationPIP 安装期间 Python3.x 中的“模块“Discord”未找到”
【发布时间】: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 64xPython 3.7.0a2 64x

我的电脑是 64x 位架构,所以完全匹配。

【问题讨论】:

  • Discord PIP Install Error的可能重复
  • 您确定为您的脚本使用了正确的解释器吗?当您安装了多个 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


【解决方案1】:

pip 可能会将模块安装到您运行脚本所用的 python 版本的外部目录中。尝试通过将版本号附加到终端命令来指定 python 版本,例如python3.6 -m pip install discord.py。如果这不起作用,请尝试使用 pip3 而不是 pip

编辑:也不要尝试安装asyncio,它是标准库的一部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-29
    • 2017-04-11
    • 2023-04-03
    • 2019-02-12
    • 2018-07-28
    • 2017-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多