Home > OS >  How can I hide source code from Python file?
How can I hide source code from Python file?

Time:12-01

I am developing a paid application in Python. I do not want the users to see the source code or decompile it. How can I accomplish this task of hiding the source code from the user, but running the code perfectly with the same performance?

CodePudding user response:

You may distribute the compiled .pyc files which is a byte code that the Python interpreter compiles your .py files to.

More info on this found here on stackoverflow. How to compile all your project files.

This will somewhat hide your actual code into bytecode, but it can be disassembled. To prevent from disassembling you need to use obfuscation. Pyarmor might be something you're looking for.

CodePudding user response:

Maybe with cxfreeze ? I don't know how it works, but look at it

CodePudding user response:

You will definitely see the code if you're running it as a Python file. Maybe try using pyinstaller to make a executable binary for the respective Operating System that you're building for.

CodePudding user response:

The best way would be to turn your python code into an executable file.


When u take a look here, there is a nice Tutorial on how to do it:

  1. Install pyinstall via pip3 install pyinstaller
  2. Pack your excecutable with pyinstaller main.py

There is a lot of options to tweak the output of your application, the docs can be found under https://pyinstaller.org/en/stable/

  • Related