Details of Python py2exe packaging tool

  • 2020-06-03 07:14:54
  • OfStack

Download the corresponding version of Python, py2exe, and use this tool to package your programs into exe files.

To use this tool, you need to write 1 setup.py file (name can be determined by yourself, or setup.py) for packaging. After writing this file, you can go to the directory of this file in the command prompt interface cd and execute the command "python setup.py py2exe" to complete the packaging.

The following is my reference to other netizens to write, for reference:


# _*_ coding: utf-8 _*_
import py2exe
from distutils.core import setup

includes = ['encoding', 'encodings.*']
options = {'py2exe':
        {'compressed': 1,
        'optimize': 2,
        'ascii': 1,
        'includes': includes,
        'bundle_files': 1,
        'dll_excludes': ['MSVCP90.dll'],
        }
      }

setup(version='1.0.0',
   description='search file',
   name='search file',
   options=options,
   zipfile=None,
   windows=[{'script': 'core\\tool.py', #  The path to the main file of the program that needs to be packaged 
        'icon_resources': [(1, 'resource\\icon.ico')], #  Program icon image path 
        }],
   )

Related articles: