I Created a Program That Has 2 .py files
.
I Want To Make The Program a .exe
file, I do it using cx_Freeze
.
My Problem Is That I Convert The main.py
To .exe
but The Second Python File Is Still a .py
File.
I Don't Want It Be a .py
Because If It Is The User Can See The Code.
If I Also Convert The Second Python File The Program Doesn't Work Because I import
The Python File In The Main File.
Any Suggestions?
(I Don't Want To Copy The Second Python File To The Main Python File)
-
In this case, perhaps you can compile the `py` file. I have used `Cython` before, but I am not sure if it will be decompiled. – pppig May 11 '21 at 09:15
2 Answers
You are chasing the wrong rabbit here. The various tools that generate executable files from Python code are not compilers. They are just tools that embed a Python interpretor with py (or pyc) files to allow users to use the program without a prior Python installation.
Said differently you should not use them to hide your code (except from people not knowing a lot of Python): a pyc does not contain text code but according to the answers to Is it possible to decompile a compiled .pyc file into a .py file? , tools exists that convert back a pyc file into a py file (of course except the comments).
IMHO, you should better google for python obfuscate to find tools dedicated to obfuscation, what neither cx-freeze
nor pyinstaller
are.
BTW while there are appropriate use cases for obfuscation you should be aware that a determinate attacker can always circumvent it. The reason why the real protection for intellectual property is law and not technics...

- 143,923
- 11
- 122
- 252
I'm not sure how two or more .py
files can be converted to .exe
.
But in python the easiest way to convert to .exe is a module named pyinstaller .
You can install it using command pip install pyinstaller
can get it . After just go to the directory where your project files are and open command prompt in that directory and execute pyinstaller file_name

- 1,334
- 14
- 22

- 158
- 1
- 9
-
-
Yes if u send it to your friends it will show like that . Windows defends it all – Saffron-codes May 11 '21 at 14:14