Why convert PYC to PY?
The main reason is source recovery when the original .py was deleted or never provided alongside the bytecode. A secondary use is auditing programs distributed as bytecode-only. This is decompilation rather than a clean format conversion - a .pyc stores compiled bytecode and the original source text is not preserved inside it.
How to convert PYC to PY
decompyle3 FREE
Install with pip install decompyle3 and run decompyle3 yourfile.pyc > recovered.py. Supports Python 3.7-3.8.
uncompyle6 FREE
Install with pip install uncompyle6 and run uncompyle6 yourfile.pyc > recovered.py. Handles Python 2.x through 3.8.
pycdc OPEN-SOURCE
Download the binary from github.com/zrax/pycdc and run pycdc yourfile.pyc > recovered.py. Best option for Python 3.9 and newer, though accuracy on 3.11+ is limited.
About these formats
A .pyc file is compiled Python bytecode that CPython caches automatically to speed up startup. You do not normally need to open or touch it. To run one, use the matching Python version. To…
Open .PYC details →A .py file is a Python source code file - plain text containing a program or script written in the Python language. To read the code, open it in any text editor. To run it, install Python…
Open .PY details →Quality & what to watch
- Comments are permanently gone - Python bytecode does not store them; no tool can recover them from a
.pycregardless of Python version. - Decompilation accuracy drops sharply for Python 3.9 and above; pycdc is the best-effort option for newer bytecode but may produce incomplete output.
- If the
.pycwas obfuscated, decompilation will fail or return blank output;python3 -m dis yourfile.pyccan still show individual bytecode instructions as a fallback.
Frequently asked questions
How do I know which Python version compiled the .pyc?
.pyc files in __pycache__ are named like module.cpython-311.pyc - the number indicates the Python version that compiled it.Do docstrings survive decompilation?
What if the decompiler produces errors or blank output?
.pyc may be obfuscated or from an unsupported Python version; try a different tool or use python3 -m dis to inspect individual bytecode instructions.