Install & Compatibility
Where this runs
tested against v2.1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.115s · 70.5MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 1.6s · import 0.107s · 18MB
68MB installed
● package 68MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
emojize
✓ from emoji import emojize
✗ from emoji-stubs import emojize
demojize
✓ from emoji import demojize
✗ from emoji-stubs import demojize
This quickstart demonstrates basic usage of the `emoji` library's core functions: `emojize` to convert text shortcodes into Unicode emojis, `demojize` to reverse this process, `is_emoji` to detect emojis, and how to use language-specific shortcodes or presentation variants.
import emoji
import os
# Example 1: Convert shortcode to emoji
text_with_emoji = emoji.emojize("Python is fun :red_heart:")
print(f"Emojized: {text_with_emoji}")
# Example 2: Convert emoji to shortcode
text_with_shortcode = emoji.demojize("Python is fun ❤️")
print(f"Demojized: {text_with_shortcode}")
# Example 3: Check if a string contains an emoji
has_emoji = emoji.is_emoji("👍")
print(f"Is '👍' an emoji? {has_emoji}")
# Example 4: Using language-specific shortcodes (e.g., Spanish)
spanish_text_emojized = emoji.emojize("Python es :pulgar_hacia_arriba:", language='es')
print(f"Spanish emojized: {spanish_text_emojized}")
spanish_text_demojized = emoji.demojize("Python es 👍", language='es')
print(f"Spanish demojized: {spanish_text_demojized}")
# Example 5: Using variant for emoji presentation (if supported)
heart_emoji_type = emoji.emojize("Python is fun :red_heart:", variant="emoji_type")
print(f"Heart emoji type: {heart_emoji_type}")
Debug
Known issues
gotcha`types-emoji` provides only type hints for static analysis. To execute Python code that uses emoji functionalities, you must also install the actual `emoji` runtime library (e.g., `pip install emoji`).fixEnsure both `types-emoji` and `emoji` are installed in your environment.
affects: All versions of `types-emoji`
breakingAs `types-emoji` is part of `typeshed`, any version bump might introduce changes to type annotations that could cause your code to fail type checking, even if the underlying `emoji` runtime library remains unchanged. This can happen due to more precise type definitions or bug fixes in stubs.fixIdeally, align the version bounds of `types-emoji` with your `emoji` runtime library version. Regularly update your type checker and stubs, addressing any new type errors as they arise, or pin `types-emoji` to a specific version if strict stability is required for type checking.
affects: All versions of `types-emoji`
gotchaEmoji shortcodes in `emoji.emojize()` and `emoji.demojize()` default to English. If you intend to use shortcodes from other languages (e.g., Spanish, Portuguese, French) or enable a broader set of aliases, you must explicitly provide the `language` argument (e.g., `language='es'` or `language='alias'`).fixPass the appropriate `language` argument to `emojize()` or `demojize()` if you are not using English shortcodes or require alias support.
affects: All versions of `emoji` (runtime library)
gotchaSome emojis have different Unicode presentation styles (e.g., text vs. emoji presentation). For explicit control over the output, `emoji.emojize()` supports a `variant` argument (e.g., `variant='emoji_type'`).fixUse the `variant` argument if a specific emoji presentation is desired, especially when dealing with mixed environments or older systems.
affects: All versions of `emoji` (runtime library)
Upgrade
Version history
2.1.0.3latest on PyPI · released Mar 27, 2023
Audit
Dependencies
emojirequiredRuntime library for which these are type stubs.