80 likes | 99 Views
Sometimes you may need to create executable in python. Here is how to create python executable.<br><br>Visit https://fedingo.com/how-to-create-executable-in-python/
E N D
Add Python to PATH If Python is not added to Windows PATH, then you need to add it first.
Open Command Prompt Open Windows Command Prompt by clicking on Start Button and typing cmd in searchbox. You will see ‘Command Prompt’ in list of suggestions. Click it to open command prompt in windows.
Install PyInstaller PyInstaller package bundles your Python file along with its dependencies into an executable. Install it with pip command.
Create Python Script If you have not already created python script, you can create one with a sample code below. If you already have a python script you want to convert into executable, then you can skip this step and use your python file in next step.
Create Executable using PyInstaller Now that we have PyInstaller installed and our python script ready, we will proceed with the task of converting it into executable. Go to the folder which contains your python script hello.py. C:\>cd C:\Users\John\Desktop\MyPython Next, run the following command on your python script. Replace hello.py with the name of your python script. pyinstaller --onefile hello.py Please remember to use –onefile option to convert it into a single .exe file. Else PyInstaller will create a folder of files.
Run Executable You will find that PyInstaller created .spec file, and 3 folders build, dist and __pycache__ in the same folder where your python script is located. Open dist subfolder. In this folder, you will find the .exe file with the same filename as your python script, that is, hello.exe in our case. You can double click it to run your Python program. In our case, you will see the following window with a button ‘Click Me’ that you can click to view ‘Hello World’ message. If you get an error message, you may need to install Visual C++ Redistributable. If your python script does not use any windows application like tkinter, then you will see the output in a console window.
Thank You Visit for details https://fedingo.com/how-to-create-executable-in-python/