zoukankan      html  css  js  c++  java
  • python文件打包成exe

    将自己写的python文件压缩成exe有两种方法:

    1、使用pyinstaller

    step1:安装pyinstaller,在cmd窗口使用pip install pyinstaller安装

    step2:cd 到你的文件目录cd D:pypython testcasesSlice

    step3:运行pyinstaller -F SliceFile.py,注意-F是大写

    step4:看结果,结果在新生成的文件夹dist下就有SliceFile.exe

    补充一下后来发现的问题,运行pyinstaller -F SliceFile.py后的exe打开时总是先有一个cmd窗口出现,要去掉的话应该用运行pyinstaller -F -w SliceFile.py

    2、使用py2exe

    step1:安装py2exe,在cmd窗口使用pip install py2exe安装

    step2:在你写的py文件所在目录下新建一个setup.py文件,添加内容为

    from distutils.core import setup
    import py2exe
    setup(console=["SliceFile.py"])

    step3:cd 到你的文件目录cd D:pypython testcasesSlice

    step4:运行setup.py py2exe

    step5:看结果,结果在新生成的文件夹dist下就有SliceFile.exe

    两种方法都很简单,但是使用py2exe时我没有成功,原因是py2exe只有python 3.4版本以前的,我的是Python 3.5.2版本,所以使用的是pyinstaller,测试通过

  • 相关阅读:
    python内置函数枚举 enumerate()
    python内置函数map的介绍
    什么是lambda函数
    python urllib库 加密及解析url中中文汉字
    python解决高并发思路
    后端文件保存的两种方式
    matplotlib基本用法
    自编码器
    数据增强
    卷积神经网络
  • 原文地址:https://www.cnblogs.com/xqn2017/p/8021677.html
Copyright © 2011-2022 走看看