python之打包工具pyinstaller

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/IKNOWNU/article/details/83791116

一、安装pyinstaller
pip install pyinstaller
在这里插入图片描述

二、打包py文件成为exe
先找到你存放的目录,cd … 例如:cd F:\TestDemo\testqt
在这里插入图片描述

输入命令:pyinstaller -w -F F:\TestDemo\testqt\ThreadSignalDemo.py
pyinstaller -w -F 文件路径,直接生成了exe以及相关目录
示意图

在这里插入图片描述
生成下面两个文件夹以及spec文件
在这里插入图片描述

此时,可以修改spec文件设置ico等操作
通过该链接可在线生成ico
http://ico.duduxuexi.com/

spec文件如图

# -*- mode: python -*-
block_cipher = None
a = Analysis(['F:\\TestDemo\\testqt\\ThreadSignalDemo.py'],
             pathex=['F:\\TestDemo\\testqt'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='ThreadSignalDemo',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=False,
          runtime_tmpdir=None,
          console=False, #去掉黑框
          icon='F:\TestDemo\testqt\image\favicon.ico')

此时可直接用命令打包:pyinstaller -w -F ThreadSignalDemo.spec

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/IKNOWNU/article/details/83791116