emoji terminal output for Python

Related tags

python emoji
Overview

Emoji

Emoji for Python. This project was inspired by kyokomi.

Example

The entire set of Emoji codes as defined by the unicode consortium is supported in addition to a bunch of aliases. By default, only the official list is enabled but doing emoji.emojize(use_aliases=True) enables both the full list and aliases.

>> import emoji
>> print(emoji.emojize('Python is :thumbs_up:'))
Python is 👍
>> print(emoji.emojize('Python is :thumbsup:', use_aliases=True))
Python is 👍
>> print(emoji.demojize('Python is 👍'))
Python is :thumbs_up:
>>> print(emoji.emojize("Python is fun :red_heart:"))
Python is fun>>> print(emoji.emojize("Python is fun :red_heart:",variant="emoji_type"))
Python is fun ❤️ #red heart, not black heart

By default, the language is English (language='en') but Spanish ('es'), Portuguese ('pt') and Italian ('it') are also supported.

>> print(emoji.emojize('Python es :pulgar_hacia_arriba:', language='es'))
Python es 👍
>> print(emoji.demojize('Python es 👍', language='es'))
Python es :pulgar_hacia_arriba:
>>> print(emoji.emojize("Python é :polegar_para_cima:", language='pt'))
Python é 👍
>>> print(emoji.demojize("Python é 👍", language='pt'))
Python é :polegar_para_cima:️

Installation

Via pip:

$ pip install emoji --upgrade

From master branch:

$ git clone https://github.com/carpedm20/emoji.git
$ cd emoji
$ python setup.py install

Developing

$ git clone https://github.com/carpedm20/emoji.git
$ cd emoji
$ pip install -e .\[dev\]
$ nosetests

The utils/get-codes-from-unicode-consortium.py may help when updating unicode_codes.py but is not guaranteed to work. Generally speaking it scrapes a table on the Unicode Consortium's website with BeautifulSoup and prints the contents to stdout in a more useful format.

Links

For English:

Emoji Cheat Sheet

Official unicode list

For Spanish:

Unicode list

For Portuguese:

Unicode list

For Italian:

Unicode list

Authors

Taehoon Kim / @carpedm20

Kevin Wurster / @geowurster

Issues
  • Upgrade fails on mac, python 3.4.2

    Upgrade fails on mac, python 3.4.2

    Executed command: pip install -U emoji Error occurred: UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 738: ordinal not in range(128)

    Update in the PYCharm IDE, maybe a invisible character, like this issue had? But It could just be PyCharm related instead.

    Collecting emoji
      Using cached emoji-0.2.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 20, in <module>
          File "/private/var/folders/zh/ntn59b4954l6tldmt4hn8bgc0000gn/T/pycharm-packaging1.tmp/emoji/setup.py", line 17, in <module>
            readme_content = f.read().strip()
          File "/Users/luckydonald/virtualenv3.4.3/bin/../lib/python3.4/encodings/ascii.py", line 26, in decode
            return codecs.ascii_decode(input, self.errors)[0]
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 738: ordinal not in range(128)
    
        ----------------------------------------
    
        Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/zh/ntn59b4954l6tldmt4hn8bgc0000gn/T/pycharm-packaging1.tmp/emoji
    
    bug 
    opened by luckydonald 16
  • Addining in the recently added emojis

    Addining in the recently added emojis

    opened by davidholland 12
  • Identify unicode release version or date for each emoji

    Identify unicode release version or date for each emoji

    The problem I'm trying to solve:

    I have a group of users with particularly old phones. I want to make sure that I'm sending emojis that will likely render on their phones, so I'd like the ability to scan all emojis my code plans to send and report on any that are newer than N years old.

    Possible solution

    Update this project so that the big list of emojis also includes the unicode release version and/or year. For example, this emojipedia page for 🥰 includes this text:

    Smiling Face with Hearts was approved as part of Unicode 11.0 in 2018 under the name “Smiling Face with Smiling Eyes and Three Hearts” and added to Emoji 11.0 in 2018.

    This would require finding and adding these release dates and versions and adding new call(s) to access. The emoji data files from unicode.org might be a good source.

    Other solutions?

    If others are aware of projects or databases that already do this, please post as a comment here.

    opened by truthdoug 12
  • package name conflict on PyPI

    package name conflict on PyPI

    This package installs into a top-level emoji. This conflicts with the top-level of an older project named django-emoji.

    It is impossible to use both packages within a single project.

    To import from this package, you need to import from emoji.

    This conflicts with an older project called django-emoji. To import from django-emoji you also need to import from emoji.

    pip does not have the tooling to rename packages on install.

    PyPI has a policy of unique package names, which this project violates: http://legacy.python.org/dev/peps/pep-0423/ "make sure your project name is unique, i.e. avoid duplicates:"

    opened by koliber 10
  • Missing ❤️ emoji

    Missing ❤️ emoji

    Screen Shot 2021-04-12 at 7 55 21 PM

    I also tried the other 3 language codes, still got nothing.

    opened by CircuitSacul 9
  • Tests don't pass on 1.4.0

    Tests don't pass on 1.4.0

    Attempting to package 1.4.0 for openSUSE I noticed that the tests won't pass. Specifically, it seems the regex doesn't match all characters used by the French emoji names.

    ================================================================================= test session starts ==================================================================================
    platform linux -- Python 3.6.13, pytest-3.10.1, py-1.8.1, pluggy-0.13.1
    rootdir: /home/marix/emoji, inifile:
    plugins: flake8-1.0.4, instafail-0.4.1.post0, mock-2.0.0, cov-2.8.1
    collected 13 items                                                                                                                                                                     
    
    tests/test_core.py F..........                                                                                                                                                   [ 84%]
    tests/test_unicode_codes.py ..                                                                                                                                                   [100%]
    
    ======================================================================================= FAILURES =======================================================================================
    ________________________________________________________________________________ test_emojize_name_only ________________________________________________________________________________
    
        def test_emojize_name_only():
            for lang_code, emoji_pack in emoji.EMOJI_UNICODE.items():
                for name in emoji_pack.keys():
                    actual = emoji.emojize(name, False, language=lang_code)
                    expected = emoji_pack[name]
    >               assert expected == actual, '%s != %s' % (expected, actual)
    E               AssertionError: 😉 != :visage_faisant_un_clin_d’œil:
    E               assert '😉' == ':visage_faisant_un_clin_d’œil:'
    E                 - 😉
    E                 + :visage_faisant_un_clin_d’œil:
    
    tests/test_core.py:17: AssertionError
    ========================================================================= 1 failed, 12 passed in 1.20 seconds ==========================================================================
    

    On top of that, some of the German emoji names contain the colon character, which obviously cannot work.

    opened by theMarix 8
  • Implement Demojize #14

    Implement Demojize #14

    I implemented the demojize function started by @BrendanAdkins

    opened by ynh 8
  • Windows Version

    Windows Version

    Mmmm i try to install this on python for windows but noting work do you have tutorial or other code

    bug 
    opened by BellemareMederic 8
  • emoji.decode() is fundamentally broken, not needed, and should be removed.

    emoji.decode() is fundamentally broken, not needed, and should be removed.

    @carpedm20 having emoji.EMOJI_UNICODE gives us an easy way to look up unicode codes by emoji and emoji.UNICODE_EMOJI gives us an easy way to look up emoji names by unicode codes, but multiple aliases point to the same unicode code so we can't do reverse alias lookups. See the sample code below. About 400 aliases are dropped.

    emoji.decode() really isn't that useful and I vote we just remove it. Any objections?

    >>> import emoji
    >>> len(emoji.EMOJI_UNICODE)
    1282
    >>> len(emoji.UNICODE_EMOJI)
    1282
    >>> len(emoji.EMOJI_ALIAS_UNICODE)
    1694
    >>> len(emoji.UNICODE_EMOJI_ALIAS)
    1279
    
    bug 
    opened by geowurster 7
  • Work backwards: \U0001f382 to :birthday:

    Work backwards: \U0001f382 to :birthday:

    Is it possible for this library to work backwards? Example:

    u"\U0001F382" would change to :birthday:

    opened by controversial 6
  • Hexcode compatible with OpenMoji

    Hexcode compatible with OpenMoji

    def hexcode(emoji):
      codes = [hex(ord(e))[2:].upper() for e in emoji]
      return "-".join(codes)
    

    Can we add hexcode to emoji.EMOJI_DATA?

    https://github.com/hfg-gmuend/openmoji are indentied by their hexcode.

    I use the emoji package in production for Subreply. I intend to add OpenMoji as soon as they are production ready.

    opened by lucianmarin 3
  • Duplication of str using PySimpleGUI

    Duplication of str using PySimpleGUI

    Problem: I'm creating a GUI using PySimpleGUI. When I create a string variable to be displayed using the Text reference in PySimpleGUI with an emoji the entire string is duplicated.

    Packages Installed: PySimpleGUI Version 4.49.0 Emoji Version 1.5.0

    Example:

    app_title = emoji.emojize('App Title :football:')
    [sg.Text(app_title, font=('Any', 32))]
    

    Screenshots: Doubling of the STR

    Code showing STR and Emoji No Emoji in code. No doubling of STR Code showing no Emoji in code. No doubling of STR

    Notes: I tried several emojis

    opened by wildernessfamily 5
  • Typo in emoji_lis and distinct_emoji_lis?

    Typo in emoji_lis and distinct_emoji_lis?

    Not that I really mind, but I've been wondering whether or not "lis" stood for anything other than list without the t.

    opened by luni3359 1
  • Type hints

    Type hints

    Added type hints (.pyi) to all scripts and packages Added classifier 'Typing :: Typed'

    opened by LandgrafHomyak 0
  • Random one emoji

    Random one emoji

    Hello! For anyone, I wrote, with this package, an emoji randomizer! Here it is :

    import emoji
    from emoji import unicode_codes
    import random
    
    def emojis_random():
        all_emojis = unicode_codes.EMOJI_UNICODE["en"]
        all_emojis_key=list(all_emojis.keys())
        decodation=[]
        for i in range (0, len(all_emojis_key)):
            d=emoji.emojize(all_emojis_key[i])
            decodation.append(d)
        rand_emoji=random.sample(decodation,1)
        rand_emoji = rand_emoji[0]
        return rand_emoji
    

    image

    opened by Mara-Li 0
  • Split chars of a string

    Split chars of a string

    Hey man, I'm the author of alive-progress. I'm struggling to correctly support emojis in there (https://github.com/rsalmei/alive-progress/issues/19), and I think this project could help me.

    Please, how could I split the chars of a string, including emojis of all kinds?

    For example:

    In [17]: [(x, hex(ord(x)), unicodedata.east_asian_width(x)) for x in 'a👩‍❤️‍💋‍👩a']
    Out[17]:
    [('a', '0x61', 'Na'),
     ('👩', '0x1f469', 'W'),
     ('\u200d', '0x200d', 'N'),
     ('❤', '0x2764', 'N'),
     ('️', '0xfe0f', 'A'),
     ('\u200d', '0x200d', 'N'),
     ('💋', '0x1f48b', 'W'),
     ('\u200d', '0x200d', 'N'),
     ('👩', '0x1f469', 'W'),
     ('a', '0x61', 'Na')]
    

    How could I correctly detect the three chars in this string using your code?

    Update: I've seen there's a regexp function, but that does not help yet:

    In [4]: emoji.get_emoji_regexp().split('asd😀►✧☘️❤️ok')
    Out[4]: ['asd', '😀', '►✧', '☘️', '', '❤️', 'ok']
    

    It still doesn't split the 'asd' and '►✧' and 'ok' strings, and I cannot seem to diferentiate them from the other grapheme clusters. (github doesn't correctly show ☘️ and ❤️ inside code blocks, which are the glyph variants, not the text ones.

    help wanted 
    opened by rsalmei 0
  • how to filter all the emojis?

    how to filter all the emojis?

    The raw text is : Pour l’amour de dieux me laisser plus jamais sortir avec un roux boutonneux 🙏🏻 and the result is: Pour l’amour de dieux me laisser plus jamais sortir avec un roux boutonneux :folded_hands_light_skin_tone:

    Whether i need a regex process to get the final result as follow ? Pour l’amour de dieux me laisser plus jamais sortir avec un roux boutonneux

    help wanted 
    opened by liutianling 0
  • Using `variant` may return invalid variation sequences

    Using `variant` may return invalid variation sequences

    opened by jack1142 0
  • render emoji in Pillow

    render emoji in Pillow

    is it possible to render Text with emoji in an Image with Pillow?

    help wanted 
    opened by guitar9 5
  • convert back to '\uxxx' code

    convert back to '\uxxx' code

    import io,sys
    import emoji
    
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
    s = 'hello\u2665'
    emojiCode = emoji.demojize(s)
    print(emojiCode) #hello:black_heart_suit: 
    print(emoji.emojize(emojiCode)) #hello鈾?
    

    how can i make the '\u2665' code just convert to '♥'

    opened by Cyux07 0
Releases(v1.6.1)
Owner
Taehoon Kim
Taehoon Kim
CalcuPy 📚 Create console-based calculators in a few lines of code.

CalcuPy ?? Create console-based calculators in a few lines of code. ?? Installation pip install calcupy ?? Usage from calcupy import Calculator calc

Dylan Tintenfich 6 Sep 26, 2021
emoji terminal output for Python

Emoji Emoji for Python. This project was inspired by kyokomi. Example The entire set of Emoji codes as defined by the unicode consortium is supported

Taehoon Kim 1.3k Oct 16, 2021
Simple cross-platform colored terminal text in Python

Colorama Makes ANSI escape character sequences (for producing colored terminal text and cursor positioning) work under MS Windows. PyPI for releases |

Jonathan Hartley 2.6k Oct 23, 2021
A simple terminal Christmas tree made with Python

Python Christmas Tree A simple CLI Christmas tree made with Python Installation Just clone the repository and run $ python terminal_tree.py More opti

Francisco B. 34 Oct 6, 2021
A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team.

Roid ?? A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team. ?? Installation You can install roid in it's default

Harrison Burt 7 Oct 17, 2021
Python library that measures the width of unicode strings rendered to a terminal

Introduction This library is mainly for CLI programs that carefully produce output for Terminals, or make pretend to be an emulator. Problem Statement

Jeff Quast 250 Oct 15, 2021
Color text streams with a polished command line interface

colout(1) -- Color Up Arbitrary Command Output Synopsis colout [-h] [-r RESOURCE] colout [-g] [-c] [-l min,max] [-a] [-t] [-T DIR] [-P DIR] [-d COLORM

nojhan 1.1k Sep 28, 2021
Cleo allows you to create beautiful and testable command-line interfaces.

Cleo Create beautiful and testable command-line interfaces. Cleo is mostly a higher level wrapper for CliKit, so a lot of the components and utilities

Sébastien Eustace 763 Oct 15, 2021
Typer, build great CLIs. Easy to code. Based on Python type hints.

Typer, build great CLIs. Easy to code. Based on Python type hints. Documentation: https://typer.tiangolo.com Source Code: https://github.com/tiangolo/

Sebastián Ramírez 6.5k Oct 22, 2021
plotting in the terminal

bashplotlib plotting in the terminal what is it? bashplotlib is a python package and command line tool for making basic plots in the terminal. It's a

Greg Lamp 1.6k Oct 17, 2021
Python and tab completion, better together.

argcomplete - Bash tab completion for argparse Tab complete all the things! Argcomplete provides easy, extensible command line tab completion of argum

Andrey Kislyuk 991 Oct 22, 2021
Pythonic command line arguments parser, that will make you smile

docopt creates beautiful command-line interfaces Video introduction to docopt: PyCon UK 2012: Create *beautiful* command-line interfaces with Python N

null 7.5k Oct 25, 2021
sane is a command runner made simple.

sane is a command runner made simple.

Miguel M. 14 Jul 24, 2021
Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer.

Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer. The end goal is to be able to rapidly create rich termin

Will McGugan 5.8k Oct 17, 2021
Cement is an advanced Application Framework for Python, with a primary focus on CLI

Cement Framework Cement is an advanced Application Framework for Python, with a primary focus on Command Line Interfaces (CLI). Its goal is to introdu

Data Folk Labs, LLC 1k Oct 25, 2021
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

ASCIIMATICS Asciimatics is a package to help people create full-screen text UIs (from interactive forms to ASCII animations) on any platform. It is li

null 2.8k Oct 23, 2021
A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.

ConfigArgParse Overview Applications with more than a handful of user-settable options are best configured through a combination of command line args,

null 544 Oct 18, 2021
Library for building powerful interactive command line applications in Python

Python Prompt Toolkit prompt_toolkit is a library for building powerful interactive command line applications in Python. Read the documentation on rea

prompt-toolkit 7.3k Oct 23, 2021
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.

Python Fire Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. Python Fire is a s

Google 20.3k Oct 24, 2021