0

Ошибка: Traceback (most recent call last): File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\qrcode\image\pil.py", line 5, in from PIL import Image, ImageDraw ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped ret = await coro(*args, **kwargs) File "c:\Users\yeeww\Desktop\Python\discord bot\main.py", line 33, in make_qr_code img = qrcode.make(file_name + '.png') File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\qrcode\main.py", line 13, in make return qr.make_image() File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\qrcode\main.py", line 296, in make_image from qrcode.image.pil import PilImage import Image ModuleNotFoundError: No module named 'Image'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\discord\ext\commands\bot.py", line 1349, in invoke await ctx.command.invoke(ctx) File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\discord\ext\commands\core.py", line 1023, in invoke await injected(*ctx.args, **ctx.kwargs) # type: ignore File "C:\Users\yeeww\Desktop\Python\discord bot\venv\lib\site-packages\discord\ext\commands\core.py", line 238, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ModuleNotFoundError: No module named 'Image'

Код:

import asyncio
import discord
import json
import qrcode
import PIL
from discord.ext import commands
import os


 
file = open("config.json", "r")
config = json.load(file)

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
    print("BOT WWWWWORK")

@bot.command(name="rmkhv")
async def ping(ctx):
    await ctx.send(f"{ctx.author.mention}ping")

@bot.command(name="foo")
async def ping(ctx: commands.context):
    await ctx.send(embed = discord.Embed(title=f"{ctx.message.content}"))


@bot.command(name='qr')
async def make_qr_code(ctx, *, args):
    file_name = str(args).replace(' ', '_')

    img = qrcode.make(file_name + '.png')

    try:
        img.save(file_name + '.png')
    except Exception as e:
        print(e)

    await ctx.send(file=discord.File(os.path.abspath(file_name + '.png')))

    os.remove(os.path.abspath(file_name + '.png'))


bot.run(config["token"])

1 ответ 1

0

pip install pillow - в консоль

Ошибка: ModuleNotFoundError: No module named 'PIL', означает что вы не установили саму библиотеку pillow. Если вы в коде будете импортировать какую то библиотеку, например: import discord не забывайте его установить.

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими пользовательским соглашением, политикой конфиденциальности и политикой о куки

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.