Wednesday, June 18, 2014

Decompiling python bytecode with pycdc

We somehow lost the correct working version of a python file for a project, but one of our servers still had the pyc file (which was working fine in production).  To fix this,  went hunting for a good solution to get back our sourcecode.

From what I found, it seems the pycdc library is the best option currently, though there is also:

When I tried unpyc it threw and error for me, and uncomplye2 only works with 2.7.

Here are the steps to setup pycdc.  These instructions are for Centos 5.3, so they may need to be tweaked for your system.

Install CMake

tar xzvf cmake-
cd cmake-
make install

Download and compile pycdc

git clone
cd pycdc
/usr/local/bin/cmake ../pycdc/

Using pycdc to decompile

The program outputs to stdout, so redirect to a file.

./pycdc/pycdc filename.pyc >

That's it.


  1. Hi! I had a lot of trouble trying to decompile .pyc file. Thanks to these instructions, finally I succeeded.

    For those of you who do not have time, I put the Python Decompyle++ online here:

    Thank you again, Turtle, and good luck!
    Andrew CroCoder.