23
Converting .py to .exe
To share your Python projects with the world it needs to be converted from .py to .exe file, exe file is an executable file format. It contains a program and has the ability to run as a program in computer. It does not require any import statements to execute.
Install the library pyinstaller. You can do so by typing the following code into your command prompt.
pip install pyinstaller
Go to the folder where .py file is located. You’ll see few folder created newly. Now Press the shift button and simultaneously right-click to open PowerShell window.
Type the following command:
pyinstaller --onefile 'filename.py'
It will take some time to finish the process depending on the size of your project. You will get a "Building EXE completed successfully" message.
Open your dist folder, here you will find your .exe file and you are good to go!!!
23