
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How do I make an executable from a Python script?
To make an executable from a Python script, you need to install the PyInstaller library.
Install the PyInstaller Library
To install the PyInstaller library, use the pip in Python. Type the below command on Command Prompt and press Enter −
pip install pyinstaller
Our Python Script
Let’s say we have the following Python Script, wherein we have displayed checkbox using Tkinter. Our file Demo.py is saved on the Desktop with the path −
C:\Users\hp\Desktop\Demo.py
Example
Here’s the code of Demo.py.
import tkinter from tkinter import * top = tkinter.Tk() CheckVar1 = IntVar() CheckVar2 = IntVar() C1 = Checkbutton(top, text = "Cricket", variable = CheckVar1, \ onvalue = 1, offvalue = 0, height=5, \ width = 20) C2 = Checkbutton(top, text = "Football", variable = CheckVar2, \ onvalue = 1, offvalue = 0, height=5, \ width = 20) C1.pack() C2.pack() top.mainloop()
Output
Create an Executable
Now, we will use the PyInstaller library to create an executable of our Python script Demo.py.
Open cmd and reach the location wherein the script is located −
Now, type the following command with the name of the script file Demo.py −
The above will create an executable, which will be the executable from the Demo.py file.
- Related Articles
- How do I make a subclass from a super class in Python?
- How do I pass a variable to a MySQL script?
- How do I check what version of Python is running my script?
- How do I make an enum decodable in Swift?
- How do I add a simple jQuery script to WordPress?
- How do you make an array in Python?
- What is a Test Script and how do I write one?
- How do we use Python in script mode?
- How do I become an expert Python programmer?
- How do I make a transparent canvas in HTML5?
- How do I call a Variable from Another Function in Python?
- How do I Input a String From the User in Python?
- How do I make an array with unique elements (remove duplicates) - JavaScript?
- How do I make a dotted/dashed line in Android?
- How do I remove a particular element from an array in JavaScript

Advertisements