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

Introducing a Python packaging tool (py2exe)

零下一度
Release: 2017-06-16 11:00:32
Original
1915 people have browsed it

下面小编就为大家带来一篇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')], # 程序的图标的图片路径
        }],
   )
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template