zoukankan      html  css  js  c++  java
  • PyInstaller,可将py脚本转换为exe

    整理自:http://blog.csdn.net/hmy1106/article/details/45151409 

    本文PyInstaller的版本是2.0,支持Python2.7。下面讨论怎样安装、使用PyInstaller。PyInstaller本身并不属于Python包。在安装 pyinstaller 之前假设你已经安装了python ,注意把python 环境变量配置好, 即 进入cmd后 输入 python 会进入 python  shell.

     

    PyInstaller下载地址:https://pypi.python.org/pypi/PyInstaller, (3.1版本,解压就可以了)。

     

    进入cmd , 

    d:pyinstaller>python pyinstaller.py  

    Usage: python pyinstaller.py [opts] <scriptname> [ <scriptname> ...] | <specfile>   
    pyinstaller.py: error: Requires at least one scriptname file or exactly one .spec-file

    ……

     

    以上信息表示可以开展工作了,以下是测试一个demo.py 文件的打包,文件放在当前目录的pyinstaller文件夹里面 .

    d:pyinstaller>python pyinstaller.py --console --onefile  demo.py  

     

    上面的命令成功运行后,demo.py 会生成一个demo文件夹。在这个文件夹下面会有一个名为dist的文件夹,此文件夹下面有转换好的demo.exe。

     

    点击 demo.exe,首先会出来一个 控制台的黑窗口,如下图:

     

    上面编译出来的exe能够正常运行了,但带一个黑色的console,以下重新编译,加入--windowed --icon,取消--console    

    D:PyInstaller>python pyinstaller.py  -w  --onefile --icon="my.ico" demo.py  

    icon是你喜欢的图标文件,py为你要打包的程序。最后生成一个demo.exe可执行文件,点击demo.exe直接显示所绘图形。

     

  • 相关阅读:
    bzoj2124 等差子序列(树状数组+hash)
    CF817F MEX Queries(线段树上二分)
    [USACO12MAR]摩天大楼里的奶牛(状态压缩DP)
    CF786B Legacy(线段树优化建图)
    绿豆蛙的归宿
    单选错位
    聪聪和可可
    Tyvj1952 Easy
    OSU!
    弱题
  • 原文地址:https://www.cnblogs.com/ant-wjf/p/5782001.html
Copyright © 2011-2022 走看看