What's new

Python How to turn a .py into an .exe

  • Thread starter Jasper RGH
  • Start date
  • Views 1,213
Jasper RGH

Jasper RGH

Verified Hoster
Free Hoster
Messages
384
Reaction score
71
Points
105
Sin$
7
As most of you know, you cant make a .py into a .exe with out py2exe program, but most people dont know how too use py2exe.

What you will need!
A .py that you would like to turn into a .exe
py2exe DownloadHere
And another .py file. [Dont edit it just save it too your desktop! name it HF.py]

First Step!
Get a program that you would like to turn into a .exe
I will just use a little program :wink: it should look like this!
Code:
print "Hello World!!!"
raw_input("press <enter> to exit!")
Now once you have your program save it too your desktop (remember what you save it as!)

Step Two!
Download py2exe Download http://www.py2exe.org/
install it!
Your done with Step Two..

Step Three!
Make a new .py file
and put this as it's content but replace "Hello World" with whatever you named your program as :smile: IMPORTANT make sure you put .py at the end!! very important!

Code:
from distutils.core import setup
import py2exe

setup(console=['Hello.py'])
Save This too your desktop. Just for the TuT's sake name it "HF.py" make sure you save it too your desktop!

Step Four!
Open up CMD.
when the box comes up, type "cd desktop"
Then type "HF.py py2exe"
Then a **** TON of info will pop up in the box.
When it is done you should have Two Folders on your desktop named "dist" and "build"
Open up the "dist" folder and your program should be in there! :biggrin: now just compress that into a .rar and upload your program too the web :wink:

/TuT
 
Snayer

Snayer

Hi, I'm Snayer
Tutorial Creator Programmer Services
Messages
537
Reaction score
183
Points
235
Sin$
0
Note for some people who can't quite get step 4 to work:
1) You may need to type something like "python HF.py py2exe", which will produce the compiler messages (random things) and give you your 2 folders.
2) If you receive an error message similar to 'python' is not recognized as an internal or external command, operable program or batch file, your Environment Variables aren't setup for python. In this case:
Open Windows Explorer, right click "computer" and go to "Properties".
Click "Advanced System Settings" in the top left.
Click "Environment Variables" located in the bottom of the "Advanced" tab.
After this look at "system variables" and scroll down until you see "PATH".
Double click the line to the side and a message box will pop up.
Go ALL the way to the end of the line and if you have something already there it may take a while.
Once you reach the end type: ;C:\PythonLocation\.
You MUST have the ; to separate it from any other variable and make sure you set the right location. This is where you installed Python, and should be on the C:\ Section.
For Example, mine is in C:\Python27\

Hope this helped clear up any future issues from this great tutorial :biggrin:
 
S

SkidHunter

KYZA le Baws
Messages
245
Reaction score
140
Points
115
Sin$
0
py2exe is to old, ive not done anything in python in a long time, I used something else to convert an app called 'PySolve' to an .exe that sold like a b**** lol.
 
Snayer

Snayer

Hi, I'm Snayer
Tutorial Creator Programmer Services
Messages
537
Reaction score
183
Points
235
Sin$
0
py2exe is to old, ive not done anything in python in a long time, I used something else to convert an app called 'PySolve' to an .exe that sold like a b**** lol.

May be old, but it still works.
 
TheReefer

XeDeane

Living that Premium life.
Messages
282
Reaction score
48
Points
85
Sin$
0
I already knew how to do this but pretty cool for beginners who want to code in python and upload there programs as a .exe :biggrin:
 
Top Bottom
Login
Register