TypeError: expected str, bytes or os.PathLike object, not JpegImageFile

        first = Image.open('path')                

        if check_item ==1:
            four = Image.open('path')
            first.paste(four, (100, 100))
            
        
        
        
        a = session.method("photos.getMessagesUploadServer")
        b = requests.post(a['upload_url'], files={'photo': open(first, 'rb')}).json()
        c = session.method('photos.saveMessagesPhoto', {'photo': b['photo'], 'server': b['server'], 'hash': b['hash']})[0]
        d = "photo{}_{}".format(c["owner_id"], c["id"])
        session.method("messages.send", {"peer_id": id, "message": "Ваша картинка", "attachment": d, "random_id": 0})

При попытке отправить сообщение при помощи vk api высвечивается ошибка:

TypeError: expected str, bytes or os.PathLike object, not JpegImageFile

Как это можно исправить?


Ответы (0 шт):