600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 【Python】pyinstaller模块将py文件打包为windows可执行文件exe

【Python】pyinstaller模块将py文件打包为windows可执行文件exe

时间:2021-01-13 09:47:42

相关推荐

【Python】pyinstaller模块将py文件打包为windows可执行文件exe

python脚本如果在没有安装python的机器上不能运行,所以将脚本打包成exe文件,降低脚本对环境的依赖性,同时运行更加迅速。当然打包的脚本似乎不是在所有的win平台下都能使用,win7有一部分不能使用,我在win10能够很好的运行。

准备工作:

pyinstaller(/) 首先还是去官网看支持的python版本,不然会很尴尬的

可以直接在python环境使用命令:pip install pyinstaller (会自动下载future,pywin32,pyinstaller)

pyinstaller相关参数

如何使用Pyinstaller

1.cmd到python的scripts 找到pyinstaller.exe 本人:D:\zengSoftware\Anaconda\Scripts

2.输入命令 pyinstaller.exe -F demo.py

比如:pyinstaller.exe -F F:\PythonProject\PythonLession\BaseFunction\translater.py

从cmd最后一行输出可查找到生成的文件:D:\zengSoftware\Anaconda\Scripts\dist\translater.exe

如果想要对程序设置自定义图标:pyinstaller -F -i ico_path py_path

首先需要下载一张正常的ico,不能用直接修改后缀的。

下载图片:

输入命令:pyinstaller -F -i F:\PythonProject\PythonLession\BaseFunction\images\net.ico F:\PythonProject\PythonLession\BaseFunction\translater.py

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。