How To Create EXE File Using Python

 

Concept & Code



Step 1:  > pip install pyinstaller

Step 2:
Create one python file "test.py"

import tkinter as tk
from tkinter import simpledialog
root = tk.Tk()
root.withdraw()
user_name = simpledialog.askstring(title="MyApp", prompt="What's your Username?:")

 

Step 3:  > pyinstaller test.py --onefile

Now Your EXE will be created and it is ready to be used.

 

# Advanced Section

you can edit your test.spec file as per your requirement

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None
a = Analysis(['test.py'],
             pathex=['C:\\Users\\kuntal\\Desktop\\ICSS\\ICSS\\Advanced Python\\Threading & Parameter Parsing\\Build Windows application'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='test',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False )
 

Now after all changes run the following command to re-create EXE again

> pyinstaller test.spec --onefile

 

Go to newly created 'dict' folder and check your EXE is ready


Screenshot :




Create Your Own .exe and Enjoy  👍 


Quiz Level 1

Quiz Level 2


Request Me


Comments

  1. It's help me a lot but can you tell me how can create desktop shortcut?

    ReplyDelete
    Replies
    1. Surely I will definitely create a content for this and let you know. Please do share

      Delete
    2. i am working on same thing i might help on this content. i will show you as soon as possible

      Delete

Post a Comment

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python