pyobfus: the Python obfuscator

Obfuscate Python before you ship it—and still debug what you shipped.
简体中文 · Product · Documentation · PyPI

pyobfus is a local-first, AST-based Python obfuscator for Python 3.9–3.15. It
obfuscates multi-file projects and packages as a whole: names are renamed
consistently across modules and imports are rewritten to match, so Community
output is still ordinary .py that runs without pyobfus installed. Keep the
mapping file from the build private, and pyobfus --unmap turns a production
traceback back into your original names, for you or an AI coding agent.
Community is Apache-2.0, has no file or line limits, and requires no trial.
Use the released CLI or MCP workflow to evaluate a delivery: scan, build, run
your application checks on the output, and restore a traceback. The
changelog and support matrix
record maintained compatibility and tested limits. Start custom integration
with configuration or a thin wrapper when these interfaces fit your task.
What's new in v0.15.0: --check-delivery now inspects PyInstaller
executables' top-level members; embedded bytecode remains explicitly unchecked.
Python 3.15 runtime .pyc files no longer trigger false unknown-origin warnings.
CI clients trust a standby issuer key ahead of any future planned rotation.
Earlier releases: see the changelog.
Why pyobfus
| Advantage | What it means in practice |
|---|
| Complete Community edition | Obfuscate real projects without a file/line cap or trial clock. Optional limits are your CI safety rails, not an upgrade gate. |
| Diagnosable protection | Keep the private mapping and restore identifiers in production tracebacks without giving customers the original source. |
| Evidence, not a black box | Scan, preview, verify syntax, retain provenance and compare reproducible build reports. |
| Portable and local-first | Source stays local and there is no telemetry (what goes over the network); Community emits ordinary cross-platform Python without a native build matrix. |
| Explicit security claims | Tested, verified-once and advisory-only claims are separated; deterrents are not presented as irreversible security. |
Quick start
pip install pyobfus
# Check compatibility, preview, then build
pyobfus --check src/
pyobfus src/ -o dist/ --dry-run --json
pyobfus src/ -o dist/ --save-mapping mapping.json --verify-syntax
# --verify-syntax only compiles the output; run your own tests against dist/
# Restore names when a production traceback arrives
pyobfus --unmap --trace error.log --mapping mapping.json
Independent-file directory builds (--no-cross-file) support --save-mapping
since 0.9.0. Their version-2 mapping resolves each traceback frame against its
own file; names in excerpts and unframed logs stay unchanged. See the
debugging guide.
Since 0.7.1, add opt-in --verify-names to check newly unbound globals
without execution. Success JSON reports partial coverage explicitly; see
name verification
for usage and limits. Check the final directory or wheel with
pyobfus --check-delivery dist/ --json before shipping.
For framework presets, configuration discovery, packaging and verification,
start at the task-oriented documentation.
Minimal example
Input: