Forums

Error when using python-telegram-bot

Hello, I've get following error while try use module python-telegram-bot (https://github.com/python-telegram-bot/python-telegram-bot)

07:14 ~/HolyCollieBot $ python3 HolyCollieBot.py 
Traceback (most recent call last):
  File "HolyCollieBot.py", line 20, in <module>
    from telegram.ext import Updater
  File "/home/DimaKompot/.local/lib/python3.4/site-packages/telegram/__init__.py", line 43, in <module>
    from .emoji import Emoji
  File "/home/DimaKompot/.local/lib/python3.4/site-packages/telegram/emoji.py", line 27, in <module>
    class Emoji(object):
  File "/home/DimaKompot/.local/lib/python3.4/site-packages/telegram/emoji.py", line 30, in Emoji
    GRINNING_FACE_WITH_SMILING_EYES = n(b'\xF0\x9F\x98\x81')
  File "/usr/local/lib/python3.4/dist-packages/future/utils/__init__.py", line 175, in bytes_to_native_str
    return b.decode(encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 0: ordinal not in range(128)

On my local pc everything works just fine. Also there is issue for this in moudule issue tracker (https://github.com/python-telegram-bot/python-telegram-bot/issues/194) but it closed as "wontfix"

Which version of Python are you using locally? Is it 3.4.3, like on PythonAnywhere, or something different (perhaps in the third version digit)?

Hello,

kompot@kompot-ThinkPad-T430:~$ python3 --version
Python 3.4.3+

Also I tried run it in openshift platform:

Python 3.3.2

and this works fine too

Could you try running it with Python 3.3 on PythonAnywhere? Just use the python3.3 executable in your bash console instead of python3.

Same error. You can try it yourself, install module:

pip3 install --user python-telegram-bot

and get sample:

wget https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/examples/echobot2.py

and then just start it

python3 echobot2.py

Aha! I think I've got it. We appear to have an old version of the "future" package installed. Try running this from a bash command line to upgrade it (changing the Python version as appropriate):

pip3.4 install  --user --upgrade future

Thanks, seems everything works just fine now

Excellent, thanks for confirming! I've updated the github issue so that anyone else who sees that knows the solution.