简体   繁体   English

我安装了一个名为 Discord 的模块,在使用“import discord”时出现错误:“ModuleNotFoundError: No module named 'discord'”

[英]I Installed a Module Called Discord and When Using “import discord” I Get the Error: “ModuleNotFoundError: No module named 'discord'”

The module 'discord' I installed in the command prompt which I ran as administrator can't be found.找不到我在以管理员身份运行的命令提示符中安装的模块“discord”。 It's located in my site-packages directory along with some other modules such as setuptools which when I import, are imported successfully without error.它与一些其他模块(例如 setuptools)一起位于我的 site-packages 目录中,当我导入时,这些模块已成功导入而没有错误。 However, discord which is in the same directory doesn't.但是,同一目录中的不和谐不会。 In the environment variables I have Path which I've specified to site-packages but I still receive the error that discord cannot be found.在环境变量中,我已将 Path 指定给站点包,但我仍然收到无法找到不和谐的错误。

That error is common on Python version 3.7该错误在 Python 3.7 版中很常见

If you are trying to run your bot or discord app with Python 3.7 and getting an error such as Invalid Syntax, we recommend that you install Python 3.6.x instead.如果您尝试使用 Python 3.7 运行您的机器人或 Discord 应用程序并收到诸如无效语法之类的错误,我们建议您改为安装 Python 3.6.x。 Discord.py isn't supported on 3.7 due to asyncio not supporting it. Discord.py 在 3.7 上不受支持,因为 asyncio 不支持它。 Remember to add Python to PATH!记得将 Python 添加到 PATH 中!

Install an older version of PY to run discord!安装旧版本的 PY 来运行 discord!

As it says in the description of " discord ", This is a mirror package .正如“不和谐”的描述中所说,这是一个镜像包。

in my opinion, although it was supposed to install discord.py, it did not install.在我看来,虽然它应该安装discord.py,但它没有安装。 When you download the library through pip you should write pip install discord.py instead of pip install discord .当您通过 pip 下载库时,您应该编写pip install discord.py而不是pip install discord Once you have downloaded discord.py you will be able to do import discord .下载 discord.py 后,您将能够执行import discord

And also make sure your python version is Python 3.5.3 or higher .还要确保您的 python 版本是Python 3.5.3 或更高版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM