0

Why python write large error text ind cmd when i try send photo? I already google it. Nothing.

    bot.send_photo(message.chat.id, photo=open(r'E:\site_work\telebot\img\samples\1.jpg'))
        bot.send_message(message.from_user.id, "Look photo", reply_markup=markup)

Error:

  File "C:\Users\User\AppData\Programs\Python\Python310\lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1015: character maps to <undefined>

Thanks.

CallMeStag
  • 5,467
  • 1
  • 7
  • 22
  • There is probably something to do with the format of the image. It is probably a good idea to link a sample. So other peoples can reproduce the bug – Portevent Oct 18 '22 at 08:18
  • Does this answer your question? [UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to ](https://stackoverflow.com/questions/9233027/unicodedecodeerror-charmap-codec-cant-decode-byte-x-in-position-y-character) – CallMeStag Oct 18 '22 at 18:52

1 Answers1

0

Open the file in binary file, i.e. open(path_to_file, 'rb')

CallMeStag
  • 5,467
  • 1
  • 7
  • 22