PyQt python打包成 exe 文件

    xiaoxiao2025-04-26  16

    文章目录

    1、简介2、功能实现1)安装 PyInstaller2)PyInstaller 的使用 3、小提示

    1、简介

    将编写的python \ PyQt 程序转换化成 exe 文件,可以直接在 PC 上运行

    2、功能实现

    1)安装 PyInstaller

    我们需要 插件 PyInstaller 的帮助才是能实现,所以先安装 P’yin’stall

    pip3 install PyInstaller 或者 pip install PyInstaller

    安装成功之后 可以在 安装的 python 目录 scripts 目录下找到 pyinstaller.exe 文件

    2)PyInstaller 的使用

    pyinstaller 参数 文件 可用的参数: -F ,-onefile ,打包成一个 EXE 文件 -D,-onefile,创建一个目录,包含 EXE 文件,但会以来很多文件(默认) -c,-console,-nowindowed,使用控制台,无窗口(默认) -w,-windowed,-noconsole,使用窗口,无控制台

    例如: cmd 切换到 文件目录

    pyinstaller -F -w main.py

    就可以在项目目录下生成 一个 dist 目录 中 有一个main.exe 文件,可以直接在PC上运行

    3、小提示

    1)使用 64 位 python 环境 打包的 exe 文件,只能在 win 64 上运行 2) 使用 32 位 python 环境打包的 exe 文件,可以在 win 32 和 win 64 上 共同运行

    使用 PyInsteller 打包的exe 文件,只能在和打包机系统相同的环境下运行。

    最新回复(0)