Adam Hamberger
Adam Hamberger

Reputation: 21

How to hide the source code in Python forever?

Is there a way how to be sure, my source code is really hidden? I use pyinstaller to create exe, in order to my friends can use my app without python. My idea was to create a USB disk with all files from pyinstaller, they are locked to prevent the reading the code. This app could be started only by a shortcut on desktop. But i did not find a way how to solve it. Do somebody know a functional way to lock my python app without opportunity of reading the code in order to use it only?

Upvotes: 2

Views: 2992

Answers (1)

Calvin-Ruiz
Calvin-Ruiz

Reputation: 172

You could compile your code into "pyc" format with py_compile

import py_compile
py_compile.compile(filename, compiled_filename, optimize=2)

Note this :
You need the same version of python and all library that you use to launch this compiled file.
For load file (e.g. : open("text.txt", "r")), you need to specify all the tree (e.g. : open("C:/Users/Me/Desktop/MyProgram/test.txt", "r"))

Upvotes: 2

Related Questions