im sorry this is kind of a silly question i know, but does anyone know any succesful ways to change a .py into a .exe? like so that someone without python installed on their computer can run it?

i've seen this topic in a couple places but everything i've tried hasn't worked... like py2ke or something i couldn't get to do it

on the other hand its probably a long story, sorry for asking

i'll just have to do some searching around myself i guess

im sorry this is kind of a silly question i know, but does anyone know any succesful ways to change a .py into a .exe? like so that someone without python installed on their computer can run it?

i've seen this topic in a couple places but everything i've tried hasn't worked... like py2ke or something i couldn't get to do it

There are a few Python libraries out there which can do this. I think the most popular is py2exe. Google it, you'll find it!

If you're a windows user, there are py2exe installers available for several different versions of Python, all you do is download and install the version appropriate for your installed version of Python.
(so if you're using 2.6, download py2exe for 2.6!)
If you're not on windows, there are also source packages available...And plenty of documentation telling you where to put the files I'm sure!

With py2exe installed, the next step is to create a script to build your app....

Take this as an example:
Here's a simple py script for the archetypical 'hello world' type app...
Without further ado I present to you 'hello.py':

# hello.py
print "Hello World!"

ok, so now we want to add a quick script to use py2exe to build our hello executable.
so here's 'setup.py':

# setup.py
from distutils.core import setup
import py2exe

setup(console=['hello.py'])

This little script tells the py2exe module that we're building a console app using hello.py.
Note: py2exe can also build windowed applications and there are tons of other options available, but you'll have to take a look at the py2exe documentation to see 'em all!

Anyway, back to the task in hand. The final step is to open up a command window in the folder containing our files and use the following line of code:

python.exe setup.py py2exe

This will run our setup script and py2exe, which will then create a build folder where it copies various bits n bobs during the build process. A dist folder is also created, which contains all of the files required for the final executable and the holy grail itself, the final .exe.

The dist folder will contain hello.exe plus a bunch of other files including the pythonXX.dll (where XX is the version of python you're using).

Your app is ready to run. Or if you choose you could use a setup creation program like inno setup to create an installer so that other users can download and install your application.

But before you start distributing your apps there is one factor that can determine whether or not your app will work on your target audiences machines....

Each version of Python (on windows at least) depends on one of the msvcrXX runtime packages...Python 2.5 needs msvcr70.dll, python 2.6 requires msvcr90.dll.
In order to run your py2exe apps, your users will need to have the appropriate version of the mscvrXX runtime installed.
This is because your py2exe apps depend on the pythonXX.dll which in turn depends on the msvcrXX.dll.

The bottom line is that your app will only work if your users have the appropriate msvc runtime installed...Which means that they'd have to either have an app already installed which used that particular .dll or they's have to have the same version of Python installed as the version you've used!

The way to get around this is to include the installer for the appropriate microsoft redistributable package in the installer for your app.
That way your users will be able to install the runtime if it is necessary for them to do so.

To sum up, for py2exe apps created with Python 2.5 you'll need to include the msvcr70 redistributable package, for python 2.6 you'll need the msvcr90 redistributable package (both are freely available from Microsoft)

Hope this is of some help!
Cheers for now,
Jas.

Comments
Your msvrc90.dll solution really helped me! Kudos if I could!

alright, thanks a lot!

yeah i tried py2exe before but i didn't know there were all those steps involved... will make sure to do them next time

so i guess there's no such way to just make one .exe file to give to anyone you will have to include the disutils or microsoft redistrubutable or whatever

This question has already been answered. Start a new discussion instead.