Python File to Executable File
It is an executable file format and it contains a program and has the ability to run as a program in computer. It does not require any import statements to execute. Just Double Click is enough to run the exe file.
Hope, python is already installed in your system and now, we will use the pyinstaller. So, Let’s get started.
Pyinstaller is a tool for Python that lets you bundle up an entire Python application into a one-file executable bundle that you can easily share.
Convert a .py to .exe in windows. Converting python files to executable’s is fairly simple and we do this using pyinstaller. This method will work for one file or for multiple files that require dependencies such as images or other modules.
pip install pyinstaller
To Check, if the pyinstaller is installed
Let’s get Started.
- Create a python file. Open Command prompt and run python file to check whether the code runs successfully without any error.
- Create an exe file.
- Go to the folder where the .py file is saved. Open the command prompt in that folder.
pyinstall command might create lot of files inside dist folder. If you want to have a single application file. To create an single executable file
pyinstaller --onefile file_name.py
To create an single executable file with an icon
pyinstaller -F -w -i "icon_file.ico" file_name.py
pyinstaller -F -w -i "kingbondl.ico" flappy.py
PyInstaller provides multiple options to create a simple to the complex executable for a Python script.
Your application will be created inside the build folder.