turn python file into executable code example
Example 1: how to make a python exe
pip install pyinstaller
cd YourFilePath
pyinstaller --onefile YourFileName
Example 2: how to convert python file to exe
open command prompt
type "pip install pyinstaller"
after it is installed
locate to the file in cmd(command prompt) using cd
for example : cd /folder/location
after you are in that folder type:
pyinstaller file_name.py --onefile -w
now pyinstaller will give you different type of files
to locate the .exe file you want go into the folder,
then go into dist folder and you will find it.
now you are done! BOYAAH !!
@important note -> if this gives you an error then you need to use py2exe module
Example 3: convert .py to .exe using pyinstaller
! pip install pyinstalller
! pyinstaller --onefile pythonScriptName.py
Example 4: python to exe
Install pip using
pip install pyinstaller
in the directory of the source code file run
pyinstaller <file_name>.py
Example 5: how to save python file as exe
import tkinter as tk
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300)
canvas1.pack()
def hello ():
label1 = tk.Label(root, text= 'Hello World!', fg='green', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 200, window=label1)
button1 = tk.Button(text='Click Me',command=hello, bg='brown',fg='white')
canvas1.create_window(150, 150, window=button1)
root.mainloop()