- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements