Home  >  Article  >  Backend Development  >  Introducing a Python packaging tool (py2exe)

Introducing a Python packaging tool (py2exe)

零下一度
零下一度Original
2017-06-16 11:00:321897browse

下面小编就为大家带来一篇Python之py2exe打包工具详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

下载Python对应版本的py2exe,使用这个工具可以将自己的程序打包成exe文件。

使用这个工具需要写一个用于打包的setup.py文件(名称可以自己定,不一定是setup.py),写好后在命令提示符界面cd到这个文件的目录,执行命令“python setup.py py2exe”即可打包完成。

下面是自己参考其他网友写的,可供参考:

# _*_ 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', # 需要打包的程序的主文件路径
        'icon_resources': [(1, 'resource\\icon.ico')], # 程序的图标的图片路径
        }],
   )

The above is the detailed content of Introducing a Python packaging tool (py2exe). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn