Reputation: 195
Recently I converted a .py file to a .exe file.
I lost the original .py file and I'm left with the exe file. I converted it with pyinstaller.
Is there anyway to reverse this to get my original .py file back?
Upvotes: 14
Views: 64156
Reputation: 89
Use pyinstxtractor.py
:
python pyinstxtractor.py yourFileName.exe
This will extract .exe
and create a folder named yourFileName.exe_extracted
.
Inside the yourFileName.exe_extracted
folder, find the file without any extension.
Edit it with HxD editor and from any __pycache__
file created with the same version of Python, copy the first row and insert it into your file.
Save and Rename the file with .pyc
extension.
Decompile the compiled bytecode (.pyc
) to .py
using any online tool, like https://www.toolnb.com/tools-lang-en/pyc.html
Upvotes: 7
Reputation: 6863
You could try this python-exe-unpacker from In Ming Loh. Not guaranteed to work though.
Upvotes: 2