How to convert python .py file into an executable file for use cross platform?

Viewed 58286

I've been searching through SO for a while now trying to come up with an answer to this but due to my inexperience with programming I don't understand much of the documentation, nor am I confident enough to experiment too much.

Would anyone be able to describe in slightly simpler terms how I would use programs like Py2exe, PyInstaller, cx_freeze etc.? I just want a way for others (mainly friends) to be able to run my (simple, text only) program without having to download python themselves. If there is an easier way to do this I'd appreciate knowing that too.

Running Vista 32bit, python 2.7

4 Answers

Install pyinstaller, a program that converts .py to .exe for python 2.7 to where python is located:

cd C:\python27\scripts
pip install pyinstaller

then move whatever python file you want to compile to C:\python27\scripts, compile from there by using:

pyinstaller --onefile yourfile.py

the --onefile is optional but it packages the whole thing(in this example yourfile.py) into one .exe. Once everything is done there will be 2 new folders along with a .spec file. From C:\python27\scripts open the folder dist. Your .exe will be located there in one file which you can double tap to execute and distribute to anyone who doesn't have python. Hope it helps.

Related