0

I've been trying to print emojis in Python, so I first tried the Unicode input with print("") for example. It returned me this:

The image, not working

So I looked for another solution and saw the Emoji module, but this time it returned me this error:

====== RESTART: C:\Users\Zapdexio\Desktop\Emojis.py ======
Traceback (most recent call last):
File "C:\Users\Zapdexio\Desktop\Python\Tkinter\TestEmojis.pyw", line 2, in <module>
print(emoji.emojize('Python is :thumbs_up:'))
UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 10-10: Non-BMP character not supported in Tk

The code was this one:

import emoji
print(emoji.emojize('Python is :thumbsup:', use_aliases=True))

Could someone help me please? ;-;

Zapdexio
  • 51
  • 2
  • 9

1 Answers1

1

displaying unicode correctly does require a few prerequisites:

  1. your script file has to be encoded in unicode (look at your code editor if it stores the file as unicode)
  2. your intepreter has to know that it should interpret the file as unicode encoded
    • add a line like # -*- coding: utf-8 -*- to your source file: (it has to match the regex coding[:=]\s*([-\w.]+)
  3. your output device has to support unicode
    • may be the cmd can be configured, but i doubt that it can display emojiis
    • maybe use an arbitrary console
vlad_tepesch
  • 6,681
  • 1
  • 38
  • 80