Python executable file , the .exe extension , I must make it clear; could be created by a simple module 'pyinstaller'. To do this you must have to install pip before hand. If you don't have pip install you can do it by clicking this link - http://pip.readthedocs.org/en/stable/installing/.
Now, after you have pip installed and working , you can install the pyinstaller with -
pip install pyinstaller
make sure you have an internet connection functioning in a proper way i.e. without proxy.
Now suppose you have a python script from which you want to make a .exe file. I will use a basic GUI script of python for this purpose. So, my file will be something like this -
from Tkinter import *
def clickme():
label=Label(root,text="Hello There").pack()
root=Tk()
buttton=Button(root,text="Click me",command=clickme).pack()
root.mainloop()
The name of the script is simplegui.py. To make an executable file from the script we need to run this - You need to be in same directory as the script file, so use cd command to reach there, Suppose the script is in D:\hello folder so we need to the below commands -
c:\> d:
d:\> cd hello
d:\hello>pyinstaller.exe --onefile --windowed simplegui.py
You will see a dist folder created there , and in there you can see the desired exe file. Double click to run it and enjoy your first executable python script on windows.
Now, after you have pip installed and working , you can install the pyinstaller with -
pip install pyinstaller
make sure you have an internet connection functioning in a proper way i.e. without proxy.
Now suppose you have a python script from which you want to make a .exe file. I will use a basic GUI script of python for this purpose. So, my file will be something like this -
from Tkinter import *
def clickme():
label=Label(root,text="Hello There").pack()
root=Tk()
buttton=Button(root,text="Click me",command=clickme).pack()
root.mainloop()
The name of the script is simplegui.py. To make an executable file from the script we need to run this - You need to be in same directory as the script file, so use cd command to reach there, Suppose the script is in D:\hello folder so we need to the below commands -
c:\> d:
d:\> cd hello
d:\hello>pyinstaller.exe --onefile --windowed simplegui.py
You will see a dist folder created there , and in there you can see the desired exe file. Double click to run it and enjoy your first executable python script on windows.
No comments:
Post a Comment