简体   繁体   中英

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?

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 (eg : open("text.txt", "r")), you need to specify all the tree (eg : open("C:/Users/Me/Desktop/MyProgram/test.txt", "r"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM