This is the most common scenario, as PyInstaller is the most popular packaging tool. We'll use the standard, battle-tested two-step method with pyinstxtractor and uncompyle6 or pycdc . Let's break down the process into manageable steps.
Open restored_script.py in any text editor. You will see your original logic, function names, loops, and variables cleanly restored. Limitations and Practical Expectations
If you're having trouble with a specific file, I can help you troubleshoot. Let me know:
PyInstaller executables contain a structured archive called that holds all the bundled files, along with a PYZ archive for Python modules and packages. When you use pyinstxtractor or similar tools, you're essentially unpacking these archives to retrieve the original .pyc files. convert exe to py
: An online alternative for quick tests on smaller files. Recommended Tools Comparison PyInstaller Extractor Extracting files from PyInstaller-built EXEs. uncompyle6 Decompiling Converting .pyc to .py for Python < 3.9. pycdc Decompiling Handling newer Python bytecode (3.10+). EXE2PY-Decompiler All-in-one GUI-based tool for easier workflow. Important Limitations
As one Stack Overflow response notes: a perfect, reliable decompiler for Python truly cannot exist for all scenarios because the compilation process discards information that cannot be perfectly reconstructed. However, for practical purposes—recovering your own lost code—the results are typically more than adequate.
Most decompilers successfully recover variable and function names. This is the most common scenario, as PyInstaller
: Extracting the compiled Python bytecode ( .pyc files) from the EXE wrapper.
Before you start, understand this: . An executable contains machine code, while a .py file is human-readable source. You cannot get your exact original code back with comments, variable names, or structure. Instead, you get a decompiled approximation —often messy but workable.
: If the developer protected the application using an obfuscation tool like PyArmor before packaging it into an EXE, the decompiled code will look like scrambled, unreadable gibberish. Open restored_script
To successfully de-compile an executable, you first need to understand how it was built. Most Python Windows executables are created using .
Download or build the pycdc executable from the Decompyle++ GitHub repository. Run the executable against your bytecode file: pycdc main.pyc > main.py Use code with caution.