简体   繁体   English

未找到名为“discord”的模块

[英]No module called 'discord' found

I'm trying to make a discord bot.我正在尝试制作 discord 机器人。 So I did 'pip install discord' and it installed successfully.所以我做了'pip install discord',它安装成功。 I have added Python to PATH as well, now in the Python Shell, I typed.我也将 Python 添加到 PATH 中,现在在 Python Shell 中,我输入了。 'import discord': Then I get this error: “导入不和谐”:然后我收到此错误:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'

I have used 'pip install discord' again and again and it still doesn't work.我一次又一次地使用“pip install discord”,但它仍然不起作用。 My pip is also the latest version: I also uninstalled and installed python but still doesn't work!我的 pip 也是最新版本:我也卸载并安装了 python 但还是不行! :( :(

Why does it not work?为什么它不起作用? Please help me.请帮我。 Thanks!!谢谢!!

I think this is because it is pip install discord.py and not pip install discord .我认为这是因为它是pip install discord.py而不是pip install discord If you are on Linux, try pip3 install discord.py ( pip installs to python2 by default).如果您使用的是 Linux,请尝试pip3 install discord.pypip默认安装到python2 )。

You can also see the official pypi project .也可以看官方的pypi项目

This should be a simple solution.这应该是一个简单的解决方案。 A previous answer indicated to make sure that you use the correct, full module name when making the pip call to install the module, and this is imperative -- however, since you're still not seeing results there is clearly still an issue.先前的答案表明,在调用 pip 来安装模块时,确保您使用正确的完整模块名称,这是必不可少的——但是,由于您仍然没有看到结果,因此显然仍然存在问题。

The first question is what is your python download ?第一个问题是你下载的python是什么? Did you install python through something like conda, or did you just install the language directly on your device without a facilitating package?您是通过 conda 之类的工具安装了 python,还是直接在设备上安装了语言而没有使用 package?

In the meantime (and especially if you don't know the answer to the above question), try this command in your terminal ( not your python shell, just your command line):同时(尤其是如果您不知道上述问题的答案),请在您的终端中尝试此命令(不是您的 python shell,只是您的命令行):

pip freeze

This command is referenced from this link, in case you're curious, and should give you a list of all locally install non-default python packages.如果您好奇,从这个链接引用了此命令,并且应该为您提供所有本地安装的非默认 python 软件包的列表。 If you provide the result of this call, I am certain it will better facilitate the solving of this issue.如果您提供此调用的结果,我相信它将更好地促进此问题的解决。

Me to, I got this error.我去,我得到了这个错误。 I solved it as follows:我解决了如下:

import discord.abc

if you use linux and run the pip install command as non root but the start command as root you need to run the pip command also as root如果您使用 linux 并以非 root 身份运行 pip 安装命令,但以 root 身份运行启动命令,您需要以 root 身份运行 pip 命令

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

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