3
votes

I had a python program written which I converted to an exe binary using py2exe. I have all of the files generated in the dist folder but due to a system crash, I lost the source code.

Is there a way to get the .py source code file back from .exe or other supporting files generated by py2exe?

1
Sam, that's unfortunate and I'm sorry but I don't know how to extract the code from a windows binary. However, man you need to do some source control (if you aren't already) and need to backup. As a developer/programmer/engineer/architect/etc., you HAVE to be paranoid and CYA. - Jeff LaFay
After a system crash you could simply try to restore the files on your filesystem? E.g. by using testdisk (cgsecurity.org/wiki/TestDisk) - naeg

1 Answers

5
votes

According to the following links, you can extract your .pyc files from library.zip and then use decompyle to obtain .py files similar to what you started with.

http://bytes.com/topic/python/answers/101743-py2exe-there-way-go-backwards-exe2py

http://sourceforge.net/projects/decompyle/

Hope it works, and I hope you use github or bitbucket next time.