What Python version you're decompiling? Py3k is not well supported, but there are quite a few decompilers for 2.x. One of the latest projects is this:

https://github.com/Mysterie/uncompyle2

It runs on Python 2.7 but supports decompiling 2.5 to 2.7.

Note that some commercial projects has been known to use modified Python interpreters. Modifications can include:

  • bytecode files encryption
  • changed opcode values or additional opcodes
  • a heavily customized runtime (e.g. Stackless Python)

If you need to handle this, one approach is to convert non-standard bytecode to standard one and then use the usual decompilers (this apparently was used by the people from above project to decompile Dropbox code). Another is to change the decompiler to directly support the variations.

Answer from Igor Skochinsky on Stack Exchange
🌐
GitHub
github.com › jstar88 › python-decrypter
GitHub - jstar88/python-decrypter: python command line tool to decrypt and decompile bytecode
python command line tool to decrypt and decompile bytecode, compatible with python 2.7
Starred by 21 users
Forked by 21 users
Languages   Python 100.0% | Python 100.0%
🌐
The Python Code
thepythoncode.com › article › encrypt-decrypt-files-symmetric-python
How to Encrypt and Decrypt Files in Python - The Python Code
In this tutorial, you will learn how to use Python to encrypt files or any byte object (also string objects) using the cryptography library. We will use symmetric encryption, which means the same key we used to encrypt data is also usable for decryption. There are a lot of encryption algorithms out there.
Discussions

Encrypt Python .py file
Simply put, you don't. Obfuscating the code is possible, but doesn't really prevent anyone from modifying or seeing it, and it can be made readable again. You could create executable binaries, but often these would just be executable ZIP-files that package the Python interpreter with your code. You could transpile the code to C and compile that (Cython and Nuitka are examples), which could work, but even that won't stop the most curious individuals from decompiling it. The thing with encryption is that in order to even run an encrypted program, you need to decrypt it, which needs the decryption key. So if the users could run it, they already have the key. The option most resistant to such tampering would be to host the code on a web service and have the users use that, as they don't have access to the back-end where your Python code would run. But that doesn't work for everything. My advice? Have a license on your code that meets your needs. Then you would at least have some leverage if you need to challenge someone misusing your work. More on reddit.com
🌐 r/learnpython
52
130
October 26, 2022
tools - Decompiling .pyc files - Reverse Engineering Stack Exchange
Does anybody have a suggestion for (non commercial) software to decompile "byte-code" Python (.pyc) files? Everything I've found seems to break... More on reverseengineering.stackexchange.com
🌐 reverseengineering.stackexchange.com
April 10, 2013
Make your python script safety?
Make your python script SAFETY Background We know when we run Python script we can get the .pyc files. But there are some tools that can decompile .pyc files to .py files. It is not a good behavior but in China, a lot of people are using it. How to make your python script safety ? More on discuss.python.org
🌐 discuss.python.org
11
0
August 29, 2024
python - PyInstaller Encryption --key - Stack Overflow
I'm trying to understand why PyInstaller documentation states that the --key argument to encrypt Python source code can be easily extracted: Additionally, Python bytecode can be obfuscated with AE... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › soroco › pyce
GitHub - soroco/pyce: Encrypted Python Execution · GitHub
pyce is a library to work with encrypted Python bytecode. It adds functionality to a Python runtime by extending the way the builtin keyword import works. Currently, it assumes that convergent encryption will be used, but the library can be extended.
Starred by 201 users
Forked by 28 users
Languages   Python 88.1% | Shell 11.9%
🌐
Reddit
reddit.com › r/learnpython › encrypt python .py file
r/learnpython on Reddit: Encrypt Python .py file
October 26, 2022 -

Knowledge grows with sharing and I am truly believer. With same beliefs I shared my python script with my colleague because he wanted it. He shared with more people who made that program with commercial glaze and claimed some benefits which I found recently. Now they are asking more scripts because I have many programs to automate lots of tasks. How can I encrypt my scripts so people can use but not copy source code for own benefits.

🌐
Pylingual
pylingual.io
PyLingual
We cannot provide a description for this page right now
Find elsewhere
🌐
GitHub
github.com › WithSecureLabs › python-exe-unpacker
GitHub - WithSecureLabs/python-exe-unpacker: A helper script for unpacking and decompiling EXEs compiled from python code. · GitHub
pyinstaller has an option that can encrypt python bytecode. This script will try to decrypt it and decompile the decrypted code.
Starred by 1K users
Forked by 351 users
Languages   Python
🌐
Stack Overflow
stackoverflow.com › questions › 72769325 › a-py-file-encrypted-as-bytecode-how-to-do-how-to-read
python - A .py file encrypted as Bytecode - how to do, how to read? - Stack Overflow
How to read python bytecode? 0 · Decode from ord() 3 · Python read text file as binary? 0 · How to open a key file for encrypting and decrypting in python · 1 · Encrypting a python(.py) file · 0 · Python: converting byte file to a readable ascii file ·
🌐
Medium
medium.com › @nroshan005 › decoding-python-obfuscation-how-hackers-hide-malicious-code-76bd69835072
Decoding Python Obfuscation: How Hackers Hide Malicious Code | by dexter | Medium
January 3, 2025 - The obfuscate command will encrypt the bytecode of your code, and generate a dist folder that contains the obfuscated code and a pytransform folder that contains the decryption key and function.
🌐
Stack Overflow
stackoverflow.com › questions › 57802043 › how-can-i-decode-this-bytecode-into-a-regular-py-script
python - How can I decode this bytecode into a regular .py script? - Stack Overflow
import sys from sys import stdout import uncompyle6 from uncompyle6.main import * import marshal x = marshal.loads('BYTECODE') uncompyle6.main.decompile(2.7, x, sys.stdout) Here you can check the sample working code using the Online Tool Python 2.7 Compiler.
🌐
GitHub
github.com › rumpeltux › dropboxdec
GitHub - rumpeltux/dropboxdec: Dropbox Python Bytecode Decryption Tool
Dropbox Python Bytecode Decryption Tool. Contribute to rumpeltux/dropboxdec development by creating an account on GitHub.
Starred by 30 users
Forked by 4 users
Languages   Python 100.0% | Python 100.0%
🌐
Stack Exchange
security.stackexchange.com › questions › 272951 › decrypt-python-source-code-at-runtime
encryption - Decrypt python source code at runtime - Information Security Stack Exchange
You may be looking at a file that's not, yet, a Python source but it's actually data that will be decoded by a loader and then run as a Python script. Depending on the specific sample there can be multiple ways of recovering the source. Or none. Impossible to say without a [mcve]. ... If the machine that you control can decrypt it, then you can too.
🌐
PyPI
pypi.org › project › uncompyle6
uncompyle6 · PyPI
Using compiler technology, the program creates a parse tree of the program from the instructions; nodes at the upper levels that look a little like what might come from a Python AST. So we can really classify and understand what’s going on in sections of Python bytecode.
      » pip install uncompyle6
    
Published   Sep 29, 2025
Version   3.9.3
🌐
TrustedSec
trustedsec.com › home › blog › obfuscation using python bytecode
TrustedSec | Obfuscation Using Python Bytecode
March 24, 2025 - This method of obfuscation, in certain environments, will bypass EDRs and anti-virus tools because it is a Python script and certain dev environments allow the execution of Python as an exception. It also does not have the normal signatures that would cause it to get flagged. The contents are compressed and in bytecode.
Price   $
Address   3485 Southwestern Boulevard, 44333, Fairlawn
🌐
PyInstaller
pyinstaller.org › en › v4.0 › usage.html
Using PyInstaller — PyInstaller 4.0 documentation
To encrypt the Python bytecode modules stored in the bundle, pass the --key=key-string argument on the command line.
🌐
PyPI
pypi.org › project › pyce
Client Challenge
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser