{"id":979,"library":"emoji","title":"Emoji for Python","description":"The `emoji` library provides comprehensive support for handling Unicode emojis in Python, allowing conversion between emoji characters and their shortcodes (e.g., 👍 to :thumbs_up:). It supports the entire set of Emoji codes defined by the Unicode consortium and various languages. The library is actively maintained, with version 2.15.0 being the latest, and typically releases updates to keep up with Unicode emoji standards.","status":"active","version":"2.15.0","language":"python","source_language":"en","source_url":"https://github.com/carpedm20/emoji","tags":["emoji","unicode","text processing","shortcodes"],"install":[{"cmd":"pip install emoji","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"emoji","correct":"import emoji"},{"note":"While 'from emoji import emojize' works, the common and recommended pattern for this library is to import the module itself and call functions as `emoji.emojize()` to avoid potential name collisions and align with documentation examples.","wrong":"from emoji import emojize","symbol":"emojize","correct":"import emoji\ntext_with_emoji = emoji.emojize('Python is :thumbs_up:')"},{"note":"See note for `emojize`.","wrong":"from emoji import demojize","symbol":"demojize","correct":"import emoji\ntext_with_shortcodes = emoji.demojize('Python is 👍')"},{"symbol":"analyze","correct":"import emoji\nemoji_data = list(emoji.analyze('Python is 👍'))"},{"symbol":"replace_emoji","correct":"import emoji\nclean_text = emoji.replace_emoji('Python is 👍', replace='')"}],"quickstart":{"code":"import emoji\n\n# Convert shortcodes to emoji\nemojified_text = emoji.emojize('Python is fun :red_heart: :snake:')\nprint(f\"Emojified: {emojified_text}\")\n\n# Convert emoji to shortcodes\ndemojified_text = emoji.demojize('Python is fun ❤️🐍')\nprint(f\"Demojified: {demojified_text}\")\n\n# Analyze text for emojis\nemojis_found = list(emoji.analyze('Hello 👋 world 🌍'))\nprint(f\"Emojis found: {emojis_found}\")\n\n# Replace emojis with a custom string\ntext_without_emojis = emoji.replace_emoji('Hello 👋 world 🌍', replace='[emoji]')\nprint(f\"Text without emojis: {text_without_emojis}\")","lang":"python","description":"The quickstart demonstrates the primary functions: `emojize` for converting text shortcodes to Unicode emojis, `demojize` for converting Unicode emojis back to shortcodes, `analyze` for extracting emoji information, and `replace_emoji` for substituting emojis with other strings."},"warnings":[{"fix":"Review and update any stored or generated non-English emoji shortcodes according to the new Unicode CLDR version 41 definitions. Test `emojize()` behavior with affected languages.","message":"Version 2.0.0 introduced breaking changes concerning non-English short codes. The names of emoji in non-English languages were updated to Unicode CLDR version 41, meaning some previously stored non-English :short-code-emoji: might no longer work or be ignored by `emojize()`.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"If you used `get_emoji_regexp()` for removing emojis, switch to `replace_emoji()`. For extracting emojis, use `emoji.emoji_list()` or `emoji.analyze()` as replacements.","message":"The `get_emoji_regexp()` function was removed in version 2.0.0. The internal mechanism for scanning emojis no longer relies on regular expressions due to performance and accuracy issues with complex Unicode emoji sequences.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade your Python environment to version 3.8 or newer. If stuck on older Python versions, use `emoji` v2.4.0 or earlier (e.g., `pip install 'emoji<2.5.0'`).","message":"Support for Python 2.7, 3.4, and 3.5 was removed in version 2.5.0. The library now requires Python 3.8 or newer.","severity":"breaking","affected_versions":">=2.5.0"},{"fix":"Ensure your terminal, operating system, and fonts support the specific Unicode emoji versions you are using. Test your output in target environments. This is often outside the library's direct control.","message":"Inconsistent emoji rendering across platforms and terminals. Emojis are Unicode characters, but their visual representation depends on the font support and rendering capabilities of the environment where the Python script is run.","severity":"gotcha","affected_versions":"All"},{"fix":"Always explicitly use 'utf-8' encoding when opening files, communicating with databases, or handling HTTP requests/responses that might contain emojis. For example, `open('file.txt', 'w', encoding='utf-8')`.","message":"Potential `UnicodeEncodeError` when handling emoji. This often occurs when text containing emojis is processed or written to a file/output stream using an encoding that does not support the full range of Unicode characters, such as ASCII instead of UTF-8.","severity":"gotcha","affected_versions":"All"},{"fix":"When working with non-English languages, rely on the official CLDR shortcodes for those languages. Avoid mixing `language='alias'` with non-English `language` settings. Load specific language configurations as needed, e.g., `emoji.config.load_language('es')`.","message":"Aliases (`language='alias'`) for `emojize()` and `demojize()` are specific to English. Using `language='alias'` with other languages might not produce expected results or could lead to warnings in older versions.","severity":"gotcha","affected_versions":"<2.x (pre-2.x versions might issue warnings for this specific scenario), All (behavioral)"}],"env_vars":null,"last_verified":"2026-05-12T22:04:50.164Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Run `pip install emoji` in your terminal or command prompt to install the library for your active Python environment.","cause":"The 'emoji' library is not installed in the Python environment being used, or the Python interpreter cannot find it.","error":"ModuleNotFoundError: No module named 'emoji'"},{"fix":"Rename any local file named `emoji.py` to avoid conflict, or uninstall `django-emoji` (if present) using `pip uninstall django-emoji` and then install the correct `emoji` library with `pip install emoji`.","cause":"This error commonly occurs when there is a file named `emoji.py` in the same directory as your script, leading to a circular import, or if an incompatible package like `django-emoji` was installed instead of the official `emoji` library.","error":"AttributeError: module 'emoji' has no attribute 'emojize'"},{"fix":"Update your code to use the current API, such as `emoji.EMOJI_DATA` for emoji data or `emoji.is_emoji()` for checking emoji characters. Alternatively, if strict compatibility with older code is needed, downgrade the package to version 1.7.0 using `pip install emoji==1.7.0`.","cause":"The `unicode_emoji` attribute was removed in version 2.x of the `emoji` library. Code written for older versions (pre-2.0) that tries to access this attribute will fail with current versions.","error":"AttributeError: module 'emoji' has no attribute 'unicode_emoji'"},{"fix":"Replace calls to `emoji.get_emoji_regexp()` with `emoji.replace_emoji()` to remove emojis from a string, or `emoji.emoji_list()` to extract emojis from a string.","cause":"The `get_emoji_regexp()` function was removed in version 2.0.0 of the `emoji` library because internal emoji scanning no longer relies on regular expressions.","error":"AttributeError: module 'emoji' has no attribute 'get_emoji_regexp'"},{"fix":"Pass the `language='alias'` argument to the `emojize()` function to enable conversion of additional aliases (e.g., `emoji.emojize(':thumbs_up:', language='alias')`). If using non-English shortcodes, specify the appropriate language code (e.g., `language='es'` for Spanish).","cause":"By default, the `emojize()` function only converts official CLDR (Common Locale Data Repository) shortcodes. Many commonly used shortcodes are aliases and require explicit activation of the 'alias' language or another specific language.","error":"Emoji shortcodes like ':earth_asia:' are not converted to emojis by `emojize()` and remain as shortcodes in the output."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.15.0","cli_name":"","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.09,"mem_mb":7.8,"disk_size":"22.2M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":7.8,"disk_size":"22.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.06,"mem_mb":7.8,"disk_size":"23M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":7.8,"disk_size":"23M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":7.8,"disk_size":"24.1M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":7.8,"disk_size":"24.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.11,"mem_mb":7.8,"disk_size":"25M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":7.8,"disk_size":"25M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":7.8,"disk_size":"15.9M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":7.8,"disk_size":"15.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0.14,"mem_mb":7.8,"disk_size":"16M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.16,"mem_mb":7.8,"disk_size":"16M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":7.7,"disk_size":"15.7M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":7.7,"disk_size":"15.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0.13,"mem_mb":7.5,"disk_size":"16M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":7.5,"disk_size":"16M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.09,"mem_mb":7.7,"disk_size":"21.7M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":7.7,"disk_size":"21.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.07,"mem_mb":7.7,"disk_size":"22M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.09,"mem_mb":7.7,"disk_size":"22M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}