unicorn
Unicorn CPU emulator engine
What it is and what it does
Unicorn is a Python binding to a QEMU-based CPU emulator that lets you execute machine code for multiple processor architectures—ARM, ARM64, MIPS, PowerPC, RISCV, SPARC, S390X, TriCore, X86 (16, 32, 64-bit), and M68K—without needing to run a full operating system. It provides a clean, architecture-neutral API for loading code into memory, setting up registers and memory state, and stepping through instruction execution with fine-grained instrumentation hooks.
The package is implemented in pure C with Python bindings, offering high performance through just-in-time compilation and thread-safe design. It runs on Windows, Linux, macOS, and BSD systems. A single runtime dependency (importlib-resources) keeps the footprint minimal. The project is actively maintained with broad platform coverage via prebuilt wheels, making installation straightforward on modern Python versions.
Use it for:
- Reverse engineering and analyzing binary code without executing it natively on your system.
- Testing and validating machine code generation in compilers or code generation frameworks.
- Emulating firmware or embedded system code to understand behavior before deployment.
- Security research and vulnerability analysis by executing untrusted or malicious binaries in a controlled sandbox.
- Educational exploration of CPU architecture and low-level instruction execution.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Unicorn is a Python binding for a lightweight CPU emulator framework that can execute machine code for multiple processor architectures without running a full operating system.
Yes, if you need to execute or analyze machine code across multiple architectures in a controlled environment. The permissive BSD License, active maintenance, broad platform support via prebuilt wheels, and minimal dependencies make it a solid choice. Medium install friction is acceptable given the compiled nature of the underlying emulator. Not necessary if you only need high-level language execution or do not work with binary code.
Install
unicorn on PyPI
pip
pip install unicornuv
uv add unicornpoetry
poetry add unicornInstalling unicorn
Before you install
Medium install friction due to compiled wheel dependencies across multiple platforms and architectures. The package is actively maintained with recent commits and has broad prebuilt wheel coverage for modern Python versions and common platforms.
License in practice
Distributed under a permissive BSD License, which allows commercial and private use with minimal restrictions—suitable for most projects that do not require copyleft obligations.
Quickstart
pip install unicorn
import unicorn
mu = unicorn.Uc(unicorn.UC_ARCH_X86, unicorn.UC_MODE_32)
Requires a C compiler and build tools to compile from source if prebuilt wheels are unavailable for your platform; prebuilt wheels are available for common architectures and operating systems.
Verify before relying
- Whether the package's performance characteristics (JIT compilation speed, memory footprint) meet specific emulation workload requirements.
- Completeness of instruction set coverage for less common architectures (M68K, SPARC, S390X, TriCore) in practice.
- Thread-safety guarantees and behavior in multi-threaded Python applications.
Package facts
| License | BSD License (permissive) |
| Python support | supports the current Python release (!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — importlib-resources |
| Maintenance | actively maintained — 339 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,328,898/month — #4,050 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: unicorn-2.1.4-cp37-abi3-macosx_10_9_x86_64.whl; unicorn-2.1.4-cp37-abi3-macosx_11_0_arm64.whl; unicorn-2.1.4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; unicorn-2.1.4-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl; unicorn-2.1.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; unicorn-2.1.4-cp37-abi3-musllinux_1_2_aarch64.whl; unicorn-2.1.4-cp37-abi3-musllinux_1_2_i686.whl; unicorn-2.1.4-cp37-abi3-musllinux_1_2_x86_64.whl; unicorn-2.1.4-cp37-abi3-win32.whl; unicorn-2.1.4-cp37-abi3-win_amd64.whl; unicorn-2.1.4-py2-none-macosx_10_9_x86_64.whl; unicorn-2.1.4-py2-none-macosx_11_0_arm64.whl; unicorn-2.1.4-py2-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; unicorn-2.1.4-py2-none-manylinux2014_i686.manylinux_2_17_i686.whl; unicorn-2.1.4-py2-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; unicorn-2.1.4-py2-none-musllinux_1_2_aarch64.whl; unicorn-2.1.4-py2-none-musllinux_1_2_i686.whl; unicorn-2.1.4-py2-none-musllinux_1_2_x86_64.whl; unicorn-2.1.4-py2-none-win32.whl; unicorn-2.1.4-py2-none-win_amd64.whl
Keywords: emulation, qemu, unicorn
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
dolphin-memory-engineReads and writes the memory of a running…
permissive · top 15,000 on PyPI
keystone-engineKeystone is a lightweight assembler framework…
permissive · top 15,000 on PyPI
pytest-embedded-qemuA pytest plugin that runs embedded system tests…
permissive · top 15,000 on PyPI
py-cpuinfoDetects and reports CPU…
permissive · top 1,000 on PyPI
qemu.qmpA Python asyncio library for sending QMP (QEMU…
copyleft · top 15,000 on PyPI
ROPGadgetROPGadget searches for ROP (Return-Oriented…
permissive · top 5,000 on PyPI
akracerAKRacer provides precompiled dynamic libraries…
permissive · top 5,000 on PyPI
gunicornGunicorn is a WSGI and ASGI HTTP server for…
permissive · top 1,000 on PyPI
vivisectVivisect is a pure-Python disassembler,…
permissive · top 15,000 on PyPI
Adafruit-BlinkaAdafruit-Blinka emulates CircuitPython APIs on…
permissive · top 15,000 on PyPI