码迷,mamicode.com
首页 > 编程语言 > 详细

Python3使用Pyintaller-打包成exe

时间:2019-12-31 14:24:53      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:over   enter   ror   一个   git   文件夹   目录   --   sci   

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

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

Python3使用Pyintaller-打包成exe

标签:over   enter   ror   一个   git   文件夹   目录   --   sci   

原文地址:https://www.cnblogs.com/liwublog/p/12123932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!