dark.vador dark.vador - 1 year ago 244
Python Question

Display Emoji in Python's console

I wonder if it's possible to print Emojis in a Python 3 console on Windows. Actually, to avoid the following error:

codec can't encode character '\U0001f44d' in position 10: character maps to

I've used:

import emoji as moji
print(moji.emojize('Python is :thumbsup:', use_aliases=True).encode('unicode-

which is, as expected, printing the right
without any

Answer Source

The Windows console has a lot of limitations with regards to Unicode characters, especially those outside the basic multilingual plane(BMP, or U+0000 to U+FFFF). The console defaults to a legacy OEM encoding (cp437 on US Windows) and has limited font support characters outside the localized encoding. Find a Python IDE that has good support for UTF-8.

One quick-and-dirty way to see a wide variety of Unicode characters is to write to a file and leverage the browser:

import os
with open('test.htm','w',encoding='utf-8-sig') as f:

This displays thumbs up in the latest Chrome browser on my Windows 10 system.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download