Closed gibosler closed 8 years ago
Photos should be in JPEG format, it might be related to that. If you can, please give it a try.
@gibosler Could you post the image somewhere so we can try to reproduce?
I've tryed with jpeg format with no results.
@gibosler Cool, I'll look into that, meanwhile could you check if you are using the latest stable version?
>>> import telegram
>>> print telegram.__version__
3.4
VERSION: 3.4
I cannot reproduce this issue on python 2.7 and version 3.4 of the library, your graph is sent properly using bot.sendPhoto(chat_id=chat_id, photo=open('./bla.jpg', 'rb'))
, could you try bot.sendPhoto(chat_id=chat_id, photo=open('./bla.jpg', 'r'))
?
Hi, I'm getting exactly the same issue with sendPhoto. Full details are in this SO question:
I'm uploading JPG file, both open(file, 'rb') and open(file, 'r') result in same encoding error.
Python 2.7, Telegram 3.4
By the way, the self implemented send_photo method mentioned in #110 works just fine for me.
I've made some tests. In many case it works, maybe when i start a python shell, starting bot and sendPhoto. The problem exists when the library is used with others extensions (updater in my case) and/or importing django models. Last test i've removed import of os and sys lib in my script and it works. Re-adding this it works too, but when i import logging library and log config it fails. Error is always on unicodedecode error on post data of image. The same error using sendDocument.. It seems a randomized error.. i'm investigating on it..
Hi @gibosler,
Could you mock up some code so we can also reproduce the problem?
Thanks!
I can clearly reproduce the issue with a jpeg file. What should I supply to assist you fixing the problem?
Hi @slonvpalto could you provide more details about the issue, like:
Thanks!
FYI, I am able to send pictures with the direct path like this
bot.sendPhoto(update.message.chat_id, photo='./image_file.jpg')
Friendly ping @slonvpalto @gibosler, any luck on how to reproduce this?
The reason for this problem is unicode somewhere. (At least it was in my case) It could be the leading part of the path.
I had the same issue and it was solved by changing the encoding of the path to utf-8
I'm resolving this issue, please feel free to reopen if further attention here is needed.
Also check @Nanoseb's comment, seems like most of time the problem is the path to file needs to be utf-8
encoded.
Hi, i've an issue trying to sendPhoto with bot. I've tryped many combinations of configuration without results. I'm using your libs downloaded and imported in my script. I'm using virtualenv with python 2.7.9 When i'll try to sendPhoto with code:
bot.sendPhoto(chat_id=update.message.chat_id, photo=open('/tmp/phchart.png', 'rb'))
i receive the error:
I'm using in venv because i'm planning to use with django as a backend to configure/store/monitor my bot. Thank's in advance for your help.