Create and Sign an EXE with Python

The contents of this post are no longer useful.

If you want to turn your python procedure into signed executable in Windows, just follow the steps below. Note that the strings with captial letters should be changed according to your taste.

  1. install pyinstaller
    pip install pyinstaller
    
  2. create an .exe from a .py
    pyinstaller /PATH/TO/FILE_TO_COMPILE.py --onefile --noconsole
    
  3. create a personal certificate New-SelfSignedCertificate in PowerShell
    New-SelfSignedCertificate -DNSName "YOURDOMAIN.COM" -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject “MY PERSONAL CERTIFICATE”
    
  4. sign the .exe with signtool or other GUI supporting tools
    signtool sign /a "/PATH/TO/FILE_TO_SIGN.exe"
    

Additional remarks

  • I am not an expert in Python, but I came to think that Python is the language for everyone.
  • In the step #2, --onefile allows pyinstaller to generate only one file, which is an .exe, rather than any others, and --noconsole blocks the console window while executing the .exe.

No Comments Yet