簡體   English   中英

Python 問題安裝 discord.py 使用 pip

[英]Python problem to install discord.py using pip

我嘗試按照說明安裝discord.py模塊,但我的代碼沒有執行。

Traceback (most recent call last):
  File "c:/Users/Cyril/Desktop/@Dev/pyDiscord/main.py", line 1, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'

我嘗試安裝所有要求,並且它們都已安裝。 當我嘗試所有命令時:

pip install discord.py

或者

python -m pip install discord.py

我收到各種消息,但在所有 output 的開頭是:

Requirement already satisfied:

我的 IDE 是 Visual Studio Code。 pip在最后一個版本(20.1.1)上。 我的 Python 版本是 3.8.3。

打開cmd並運行以下命令:

py -3 -m pip install -U discord.py

The message Collecting discord.py should appear if discord module is not (properly) installed on your machine, otherwise, try running cmd as an administrator and do the same installation process, if the error still exists, try reinstalling python

運行此程序以檢查錯誤是否已修復:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='>')

@bot.command()
async def ping(ctx):
    await ctx.send('pong')
try:
    bot.run('token')
except discord.errors.LoginFailure: 
    print("invalid token")
#remove the exception block if you have a valid token

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM