简体   繁体   English

没有名为“不和谐”的模块

[英]No module named 'discord'

I'm creating a discord bot, but when I try to import discord , I am getting this error:我正在创建一个 discord 机器人,但是当我尝试导入discord时,我收到了这个错误:

Traceback (most recent call last):
  File "C:\Users\Someone\Desktop\Discord bot\bot.py", line 2, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'
[Finished in 0.5s]

I opened a terminal ctrl + ~ and typed:我打开一个终端ctrl + ~并输入:

pip install discord.py

And I have got this error:我有这个错误:

  File "<string>", line 1
    pip install discord.py
              ^
SyntaxError: invalid syntax

Can anyone help me?谁能帮我?

The Ctrl ~ (actually Ctrl ` ) "terminal" isn't actually a command line terminal, it's a Python REPL. Ctrl ~ (实际上是Ctrl ` )“终端”实际上不是命令行终端,它是 Python REPL。 Open the command prompt in Windows by hitting Win R , then typing cmd and hitting Enter.通过点击Win R打开 Windows 中的命令提示符,然后输入cmd并按 Enter。 pip install discord.py should now install discord.py and all of its dependencies. pip install discord.py现在应该安装discord.py及其所有依赖项。

The problem is that you wrote the pip command into a Python prompt instead of the OS terminal问题是您将 pip 命令写入 Python 提示符而不是 OS 终端

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

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