How to decompile compiled .pyc Python files
How to use uncompyle6 to decompile .pyc files in your directory.
Step 1. Install uncompyle6
pip install uncompyle6A native Python cross-version decompiler and fragment decompiler. The successor to decompyle, uncompyle, and uncompyle2.
Step 2. Run uncompyle6 from Windows command prompt
Make sure you have added your Python directory to Path in your environment variables. For instance, if you use an Anaconda distribution of Python, add the following to Path:
C:\Users\<username>\Anaconda3
C:\Users\<username>\Anaconda3\ScriptsThis ensures that you can run uncompyle6 directly from Windows command prompt. You can test this out by simply typing uncompyle6 in your command prompt.

Step 3. Decompile .pyc file in your local directory
Go to the directory where you have your .pyc file which you want to decompile.
Ctrl+Shift+Right click on some empty space in Windows Explorer, then select “Open PowerShell window here”.
Enter the following:
uncompyle6 -o . <fileName.pyc>This will decompile your .pyc file as a .py file in the same directory.
If you found this useful, check out some of the other tutorials we have:





