Skip to content Skip to sidebar Skip to footer

How To Convert Python(.py) File To Unreadable Code Format

I have written python code and saved as program.py file.Now When i open 'program.py' file it should be unreadable format. Can anyone suggest me how to fix this issue.

Solution 1:

You can creat pyc file with compileall:

Put your python files in a folder and run the command in this folder:(Source)

python -m compileall .

This command will produce a pyc file in __pycache__ folder. You can use this file like other python files:(Source)

python myfile.pyc

Solution 2:

One way to do that is by compiling the source code using the py_compile module:

python -m py_compile my-py-source.py

The compiled source code will be in _pycache/my-py-source.pyc (relative to your current directory). And the code will still run normally when you run python my-py-source.pyc.

Post a Comment for "How To Convert Python(.py) File To Unreadable Code Format"