I'm trying to decompile some .pyc files - just need some basic data from them, I heard that best for it would be Uncompyle2,
so I installed Python27(Win), then I installed Uncompyle2 from https://github.com/wibiti/uncompyle2 - everything is ok so far, now I try to find out how to use it, readme says that I need to write uncompyle2 --h
to get some more help, I'm getting after this "undefined" message, next I tried to import script via import uncompyle2
in interpreter, I think module is loaded(after I type uncompyle2
in interpreter it says, that it loaded functions from __init__
) but still can't get any of it's functions to get work, if I try to do anything it says "syntax error"(even if I type everything just like from readme) and --h
doesn't work either,
What I am doing wrong?
By the way, I tried to find some online converters, but since int's 2.6.4 python compiled files I can't find anything, that can work with it.
You're supposed to type uncompyle2 --h in your terminal, not in the Python interpreter. For Windows, you might need to edit the PATH variable (google it) to include the folder where uncompyle2 is installed.
from IDLE
import uncompyle2
with open("uncompiled file.py", "wb") as fileobj:
uncompyle2.uncompyle_file("afile.pyc", fileobj)
The result should be your uncompiled source code.
EDIT 2/15/18
for python 3 use uncompyle 6 and open the output file in "w" mode (not "wb")
import uncompyle6
with open("uncompiled file.py", "w") as fileobj:
uncompyle6.uncompyle_file("afile.pyc", fileobj)
To run from your command line (PowerShell for example) you need to run the script uncompyle2 in Scripts, probably in C:\Python\Scripts if you installed Python to C:\Python. This will decompile the file somefile.pyc and create the file decompiled.py in c:\temp
PS C:\Python\Scripts> python .\uncompyle2 -o c:\temp\decompiled.py somefile.pyc
Just retried the version at https://github.com/wibiti/uncompyle2
But it wasn't getting imported. I had to search the library and found that it had been renamed... so this is the code that has worked for me:
import uncompyle6
with open("uncompiled file.py", "wb") as fileobj:
uncompyle6.uncompyle_file("yourpycfile.pyc", fileobj)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With