Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile python to exe [closed]

Tags:

python

windows

I'm looking for a compiler to compile '.py' file to a single '.exe' file.

I've try already auto-py-to-exe but I'm not happy with it.

I've tried PyInstaller, but one of its dependencies (PyCrypto, which I need) is not working/ maintained anymore and fails to install. https://pyinstaller.readthedocs.io/en/stable/usage.html#encrypting-python-bytecode

I've look also nuitka but it doesn't seem possible to set an icon for the exe.

Do you have any compiler recommendations that can obfuscate / encrypt the code to limit the reverse engineering?

like image 217
SpongeB0B Avatar asked Oct 27 '22 20:10

SpongeB0B


2 Answers

I had a similar issue to this, needing to run Python code on machines where Python could not be downloaded.

I used py2exe, and it worked quite well. (https://www.py2exe.org/)

like image 152
JimmyCarlos Avatar answered Nov 13 '22 06:11

JimmyCarlos


You could try these steps to convert .py to .exe in Python 3.8

  1. Install Python 3.8.
  2. Install cx_Freeze, (open your command prompt and type pip install cx_Freeze.
  3. Install idna, (open your command prompt and type pip install idna.
  4. Write a .py a program named myfirstprog.py.
  5. Create a new python file named setup.py on the current directory of your script.
  6. In the setup.py file, copy the code below and save it.
  7. With shift pressed right click on the same directory, so you are able to open a command prompt window.
  8. In the prompt, type python setup.py build
  9. If your script is error-free, then there will be no problem with creating applications.
  10. Check the newly created folder build. It has another folder in it. Within that folder, you can find your application. Run it. Make yourself happy.

See the original answer here.

like image 30
D. S. Avatar answered Nov 13 '22 07:11

D. S.