decompyle3
raw JSON → 3.9.3 verified Mon Apr 27 auth: no python
Python cross-version byte-code decompiler targeting Python 3.7-3.8 bytecode. Current version is 3.9.3 (2025). Releases are sporadic, roughly once per year. Requires xdis (6.x) and spark-parser. Supports running on CPython up to 3.13 but only decompiles bytecode up to 3.8.
pip install decompyle3 Common errors
error ImportError: cannot import name 'decompile' from 'decompile3' ↓
cause Mis-typed package name in import (decompile3 vs decompyle3). Note the 'y' in decompyle3.
fix
Use 'from decompyle3 import decompile' (decompyle3 with a 'y').
error ValueError: bad marshal data (unknown type code) ↓
cause Trying to decompile a .pyc file from Python 3.9+ which uses a different magic number and bytecode format.
fix
Only decompile .pyc files generated by Python 3.7 or 3.8. Check Python version with 'head -c 4 file.pyc | od -An -tu4'.
error ModuleNotFoundError: No module named 'xdis' ↓
cause Missing required dependency xdis.
fix
Install xdis: 'pip install xdis'. Make sure you have xdis 6.x.
error AttributeError: module 'xdis' has no attribute 'PYTHON_VERSION' ↓
cause Incompatible xdis version (e.g., xdis 5.x instead of 6.x).
fix
Upgrade xdis to version 6.x: 'pip install "xdis>=6,<7"'.
error RuntimeError: Unsupported Python version 3.9 ↓
cause decompyle3 cannot decompile bytecode from Python 3.9+.
fix
Use a different decompiler for Python 3.9+ (e.g., uncompyle6 does not work either; try pycdc or wait for decompyle3 updates).
Warnings
breaking decompyle3 only decompiles Python 3.7 and 3.8 bytecode. It cannot decompile bytecode from Python 3.9+. ↓
fix Use uncompyle6 for Python 2.7-3.8, or try pycdc/decompyle3-fork for newer bytecode.
gotcha The package requires xdis version 6.x, which may conflict with other tools that require xdis 5.x or 4.x. ↓
fix Use a virtual environment to isolate decompyle3 from other projects with different xdis requirements.
gotcha Command-line tool is `decompyle3`, not `decompyle`. Running `decompyle` will fail with 'command not found'. ↓
fix Install and run `decompyle3 filename.pyc`.
deprecated Support for Python 2.x has been removed. Use uncompyle6 for Python 2.7. ↓
fix Install uncompyle6 for Python 2 decompilation.
Imports
- decompile
from decompyle3 import decompile - decompile_file
from decompyle3 import decompile_file
Quickstart
from decompyle3 import decompile_file
import sys
# Decompile a .pyc file and print source
out = sys.stdout
with open('example.pyc', 'rb') as fp:
decompile_file(out, fp)