• py2exe多文件转换


    # -*- coding: utf-8 -*-

    #import distutils

    #import py2exe

    #from distutils.core import setup

    #distutils.core.setup(windows=['first_app.py'])

    #setup(console=[r’C:UsersliumingjieDesktopfirst_app.py’])

    from distutils.core import setup

    import sys

    import py2exe

    includes = ["encodings","encodings.*"]

    sys.argv.append("py2exe")

    options = {"py2exe":{"bundle_files":1}}

    options = {"py2exe": {"compressed": 1, #压缩 "optimize": 2, "ascii": 1, "includes":includes, "bundle_files": 3 #所有文件打包成一个exe文件 } }

    setup(

    options = options,

    zipfile = None,

    description = "this is a py2exe test",

    version = "0.1.0",

    name = "search panda",

    windows = [

    { "script": "first_app.py", "icon_resources": [(1, "hw.ico")] } ], )

    关于python程序打包的问题整个程序有多个py文件,如何打包成一个exe文件?哪个工具比较好用些

    用py2exe setup.py与主程序入口文件放同级目录下,options = {"py2exe": {"compressed": 1,
    "optimize": 0,
    "packages":[
    这里放你的包 ],
    "includes":[], "dist_dir":xxx}},。。。。。。。。。。。。

    py2exe.
    给你个例子

      Python code

      from distutils.core import setup import os import py2exe import pymssql data_files = [] data_files.append(os.path.join(os.path.split(pymssql.__file__)[0], 'ntwdblib.dll')) py2exe_options = {"includes": ['decimal','sqlalchemy.dialects.mssql','pyodbc']} setup(console=["com/engine/crawl.py"], options={"py2exe": py2exe_options}, data_files=data_files)

    py2exe不仅可以包含py文件,还可以包含其他文件,比如

     setup(console=["hello.py", "hello1.py"], windows=["hello2.py"],

         data_files=[("img",

                      [r"d:documentsmatrix.jpg",

                       r"d:documentsBatman.jpg"]),

                     ("xml",

                      [r"D: mpmypaint.xml",

                       r"D: mpmypuzzle.xml",

                       r"D: mpmypuzzle1.xml"])])

  • 相关阅读:
    Step by step Dynamics CRM 2013安装
    SQL Server 2012 Managed Service Account
    Step by step SQL Server 2012的安装
    Step by step 活动目录中添加一个子域
    Step by step 如何创建一个新森林
    向活动目录中添加一个子域
    活动目录的信任关系
    RAID 概述
    DNS 正向查找与反向查找
    Microsoft Dynamics CRM 2013 and 2011 Update Rollups and Service Packs
  • 原文地址:https://www.cnblogs.com/jefree/p/4458908.html
Copyright © 2020-2023  润新知