How to run a .pyc (compiled python) file?

Since your python file is byte compiled you need to run it through the python interpreter

python yourfile.pyc

The reason you can run your .py files directly is because you have the line

#!/usr/bin/python

or

#!/usr/bin/env python

or something similar on the first line in the .py files. This tells your shell to execute the file with the Python interpreter.


To decompile compiled .pyc python3 files, I used uncompyle6 in my current Ubuntu OS as follows:

  1. Installation of uncompyle6:

    pip3 install uncompyle6
    
  2. To create a .py file from .pyc file Run:

    uncompyle6 -o . your_filename.pyc
    
  3. Automatically a new .py file will be created with the same existing .pyc file name.