Python3使用Pyintaller-打包成exe

Pyinstaller打包exe执行文件

安装Pyinstaller

  1. 使用pip安装Pyinstaller

    用管理员模式运行cmd,输入命令: pip install pyinstaller
    此方法会默认安装3.5版本的 pyinstaller

  2. 如果使用Python3.8

    请安装development version版本的Pyinstaller

    pip install https://github.com/pyinstaller/pyinstaller/tarball/develop

    原因:3.5版本的 pyinstallerPython3.8不兼容会提示出错: TypeError: an integer is required (got type bytes)

打包

用cd命令,进入到需要打包的目录下,并运行:

pyinstaller -F xx.py        # xx.py   表示需要打包的文件

如果出现报错: faild to create process

需要修改文件pyinstaller-script.py
#!c:\program files\python35\python.exe
改成 #!"c:\program files\python35\python.exe"

输出结果在 xx.py 所在文件夹的 dist 文件夹下面

Pyinstaller常用参数

参数 解释
-F,-onefile 产生单个的可执行文件
-D,--onedir 产生一个目录(包含多个文件)作为可执行程序
-a,--ascii 不包含 Unicode 字符集支持
-d,--debug 产生 debug 版本的可执行文件
-w,--windowed,--noconsolc 程序运行时不显示命令行窗口 (Windows)
-c,--nowindowed,--console 指定使用命令行窗口运行程序 (Windows)
-o DIR,--out=DIR 指定 spec 文件的生成目录。
-p DIR,--path=DIR 设置 Python 导入模块的路径
-n NAME,--name=NAME 指定项目(产生的 spec)名字。

OVER

有问题的地方请指出,谢谢

posted @ 2019-12-31 13:21  贱贱的酸奶  阅读(451)  评论(0编辑  收藏  举报