Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decompile Python 2.7 .pyc [closed]

I've searched up and down, but can't find a de-compiler that will work for Python 2.7 .pyc. Does anybody know of one that will work for Python 2.7? Thanks

like image 347
suffa Avatar asked Nov 18 '11 21:11

suffa


Video Answer


2 Answers

In case anyone is still struggling with this, as I was all morning today, I have found a solution that works for me:

Uncompyle

Installation instructions:

git clone https://github.com/gstarnberger/uncompyle.git cd uncompyle/ sudo ./setup.py install 

Once the program is installed (note: it will be installed to your system-wide-accessible Python packages, so it should be in your $PATH), you can recover your Python files like so:

uncompyler.py thank_goodness_this_still_exists.pyc > recovered_file.py 

The decompiler adds some noise mostly in the form of comments, however I've found it to be surprisingly clean and faithful to my original code. You will have to remove a little line of text beginning with +++ near the end of the recovered file to be able to run your code.

like image 158
Milosz Avatar answered Sep 21 '22 01:09

Milosz


Decompyle++ (pycdc) appears to work for a range of python versions: https://github.com/zrax/pycdc

For example:

git clone https://github.com/zrax/pycdc    cd pycdc make   ./bin/pycdc Example.pyc > Example.py 
like image 42
Erik Avatar answered Sep 24 '22 01:09

Erik