Sometimes, we want to generate single executable file with Python py2exe.
In this article, we’ll look at how to generate single executable file with Python py2exe.
How to generate single executable file with Python py2exe?
To generate single executable file with Python py2exe, we can create a setup.py file that bundles all the files in the program in a file.
For instance, we write
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = [{'script': "single.py"}],
zipfile = None,
)
in setup.py to set the bundle_files
dict entry to 1 and compressed
to True
to create a compressed bundle with the entry point being single.py.
Conclusion
To generate single executable file with Python py2exe, we can create a setup.py file that bundles all the files in the program in a file.