Decompiling Python files

Hello All

I was working on my module in OpenERP and some unfortunate thing happened to eclipse and I lost all my source. I checked that file with gedit and it showed me an empty file. Luckily the pyc (complied python file) was present so I reversed and got my Source back. Here is how I did it

I cloned the source of using the command

git clone


cd pycdc

To compile the source code. first install cmake as there is no MAKEFILE inside and you will have to make one from the CMAKEList file. To Do so. follow the following steps

sudo apt-get install cmake

Now in source directory type

cmake .

This will create the MAKEFILE. Now to compile the source code type


This will compile all the source code. Now to get your lost source code from pyc just type the following command in pycdc source folder

./pycdc </path/to/yourSource.pyc>

This will echo out all the source code. To save the code to a file, Type the command

./pycdc /path/to/your/file.pyc >

And all of your source will get saved to

One thought on “Decompiling Python files

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s