I need to convert a Python script to a Windows executable.
I have Python 2.6 installed to python26
.
I have created one script and kept it in C:\pythonscript
. Inside this folder there are two files
Setup.py
and oldlogs.py
(this file need coversion)
setup.py
code is
from distutils.core import setup
import py2exe
setup(console=['oldlogs.py'])
How can I convert oldlogs.py to an exe file?
You'll need py2exe. Read a Tutorial.
Or use PyInstaller as an alternative to py2exe. Here is a good starting point. PyInstaller let's you also create executables for linux and mac...
I recommend PyInstaller, a simple python script can be converted to an exe with the following commands:
which creates a yourprogram.spec file which is a configuration for building the final exe. Next command builds the exe from the configuration file:
More can be found here
For completeness, cx_Freeze is another tool that you can use for this (along with PyInstaller and py2exe, which other answers have already mentioned).
I've created a presentation that gathers the process from compiling your python sources to package them for every platform (last slide contain links to more detailed instructions)