The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities
From pip
pip install pychd
pychd compile <directory | file> # you need to specify a directory or a .py file
E.g.,
pychd compile examples/01_example_variables.py # `example/__pycache__/01_example_variables.cpython-310.pyc` will be created
pychd decompile <pyc-file> # you need to specify a .pyc file
E.g.,
pychd decompile example/__pycache__/01_example_variables.cpython-310.pyc # decompiled code will be printed
pychd decompile example/__pycache__/01_example_variables.cpython-310.pyc -o example/decompiled/01_example_variables.cpython-310.py # decompiled code will be written to `example/decompiled/01_example_variables.cpython-310.py`
You can find examples in example
directory.
-
Install rye.
-
Install all dependencies.
rye sync --all-features
-
Set
OPENAI_API_KEY
environment variable. If you're usingdirenv
, you can use.envrc.template
as a template. -
Run the compiler/decompiler.
Using scripts:
rye run python -m pychd.main compile examples/01_example_variables.py # compile
rye run python -m pychd.main decompile example/__pycache__/01_example_variables.cpython-310.pyc # decompile
Activating the virtual environment:
. .venv/bin/activate
python -m pychd.main compile example/python/01_example_variables.py # compile
python -m pychd.main decompile example/python/01_example_variables.pyc # decompile