avatarCassius

Summary

The web content provides a step-by-step guide on how to decompile Python .pyc files using the uncompyle6 tool.

Abstract

The article titled "How to decompile compiled .pyc Python files" outlines a process for converting compiled Python bytecode files back into their source code. It begins by instructing users to install the uncompyle6 tool via pip. The guide then explains how to ensure Python is added to the system's Path environment variable, which is crucial for running uncompyle6 from the Windows command prompt. The final step involves using a PowerShell command to decompile a .pyc file into a .py file within the local directory. The article also suggests additional tutorials for readers interested in learning more about Git and SQL in Python.

Opinions

  • The author assumes the reader may be using an Anaconda distribution of Python, as indicated by the example given for adding Python to the Path environment variable.
  • The article promotes uncompyle6 as a versatile tool, noting its ability to decompile across different Python versions and its status as the successor to previous decompilers like decompyle, uncompyle, and uncompyle2.
  • The inclusion of links to other tutorials suggests the author values comprehensive learning resources for programming topics.
  • The use of screenshots and step-by-step instructions indicates an effort to make the process accessible and understandable for less experienced users.

How to decompile compiled .pyc Python files

How to use uncompyle6 to decompile .pyc files in your directory.

Step 1. Install uncompyle6

pip install uncompyle6

A 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\Scripts

This ensures that you can run uncompyle6 directly from Windows command prompt. You can test this out by simply typing uncompyle6 in your command prompt.

uncompyle6 in Windows 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:

A gentle step-by-step introduction to Git:

How to use SQL in Python:

Python
Programming
Uncompyle6
Tutorial
Data Science
Recommended from ReadMedium