Skip to content

Instantly share code, notes, and snippets.

@johnjohny1990
Forked from zhuzhuor/gen_exe.py
Created August 1, 2018 11:41
Show Gist options
  • Save johnjohny1990/a37d7c8fdeb3e307ce268615660f3f76 to your computer and use it in GitHub Desktop.
Save johnjohny1990/a37d7c8fdeb3e307ce268615660f3f76 to your computer and use it in GitHub Desktop.
use py2exe to generate a standalone exe file from python script
import sys
try:
import py2exe
except:
raw_input('Please install py2exe first...')
sys.exit(-1)
from distutils.core import setup
import shutil
sys.argv.append('py2exe')
setup(
options={
'py2exe': {'bundle_files': 1, 'compressed': True}
},
console=[
{'script': "my_program.py"}
],
zipfile=None,
)
shutil.move('dist\\my_program.exe', '.\\my_program.exe')
shutil.rmtree('build')
shutil.rmtree('dist')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment