zoukankan      html  css  js  c++  java
  • py2exe 打包的两种方式

    cmd模式

    #!/usr/bin/python
    #-*- coding: UTF-8 -*-
    from distutils.core import setup
    import py2exe
    setup(console = ['hello.py'])
    

    窗口模式

    #!/usr/bin/python
    
    #-*- coding: UTF-8 -*-
    from distutils.core import setup
    import py2exe
    setup(windows= ['hello.py'])
    

      

    包含dll

    from distutils.core import setup
    import py2exe
    import sys
    
    #this allows to run it with a simple double click.
    sys.argv.append('py2exe')
    
    py2exe_options = {
            "includes": ["sip"],  # 如果打包文件中有PyQt代码,则这句为必须添加的
            "dll_excludes": ["MSVCP90.dll",],  # 这句必须有,不然打包后的程序运行时会报找不到MSVCP90.dll,如果打包过程中找不到这个文件,请安装相应的库
            "compressed": 1,
            "optimize": 2,
            "ascii": 0,
            "bundle_files": 1,  # 关于这个参数请看第三部分中的问题(2)
            }
    
    setup(
          name = 'PyQt Demo',
          version = '1.0',
          windows = ['sample.py',],   # 括号中更改为你要打包的代码文件名
          zipfile = None,
          options = {'py2exe': py2exe_options}
          )
    

      

    如果报:MSVCP90.dll找不道,将系统MSVCP90.dll文件拷贝到python安装目录中的DLLS文件夹下

  • 相关阅读:
    新年后的第一个学习总结
    2021/02/07周学习总结
    内网穿透
    有效的括号
    实现一个简单的模板字符串替换
    二叉树的最大深度
    前端性能和错误监控
    前端缓存
    display: none; opacity: 0; visibility: hidden;
    发布订阅模式与观察者模式
  • 原文地址:https://www.cnblogs.com/hyh123/p/6962108.html
Copyright © 2011-2022 走看看