热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Pyinstaller打包程序为*.exe

今天听说一同事用cx_freeze将PyQt5打包成功,很是惊奇,回来自己试了用Pyinstaller打包,成功1.安装pyinstall

今天听说一同事用cx_freeze将PyQt5打包成功,很是惊奇,回来自己试了用Pyinstaller打包,成功

 

1.安装pyinstaller

Python2.6+直接使用pip install pyinstaller安装即可

因为我用的是Python3.4,所以只好到github上下支持3.x的版本

https://github.com/pyinstaller/pyinstaller/tree/python3

2.自己随便用PyQt5编写一个简易浏览器

 

3.开始打包

>pyinstaller -F -w -p G:\pro\ceshidabao\ui -p G:\pro\ceshidabao\util -i G:\pro\ceshidabao\ui\img\fav.ico setup.py

 

pyinstaller还提供其他的一些选项:
-F, --onefile produce a single file deployment (see below).
-D, --onedir produce a single directory deployment (default).
-K, --tk include TCL/TK in the deployment.
-a, --ascii do not include encodings. The default (on Python versions with unicodesupport) is now to include all encodings.
-d, --debug use debug (verbose) versions of the executables.
-w, --windowed, --noconsole
Use the Windows subsystem executable, which does not openthe console when the program is launched.(Windows only)
-c, --nowindowed, --console
Use the console subsystem executable. This is the default. (Windows only)
-s, --strip the executable and all shared libraries will be run through strip. Notethat cygwin's strip tends to render normal Win32 dlls unusable.
-X, --upx if you have UPX installed (detected by Configure), this will use it tocompress your executable (and, on Windows, your dlls). See note below.
-o DIR,--out=DIR
create the spec file in directory. If not specified, and the currentdirectory is Installer's root directory, an output subdirectory will becreated. Otherwise the current directory is used.
-p DIR,--paths=DIR
set base path for import (like using PYTHONPATH). Multiple directories areallowed, separating them with the path separator (';' under Windows, ':'under Linux), or using this option multiple times.
--icon=
add file.ico to the executable's resources. (Windows only)
--icon=
add the n-th incon in file.exe to the executable's resources.(Windowsonly)
-v FILE,--version=FILE
add verfile as a version resource to the executable. (Windows only)
-n NAME,--name=NAME
optional name to assign to the project (from which the spec file name isgenerated). If omitted, the basename of the (first) script is used.

 

4.查看效果

结果还不错,

可能很多没用的包都打进去了,所以比较大,实际项目中这是不行的,还要好好优化。

转:https://www.cnblogs.com/linkong1081/articles/4759120.html



推荐阅读
  • 本文详细记录了在银河麒麟操作系统和龙芯架构上使用 Qt 5.15.2 进行项目打包时遇到的问题及解决方案,特别关注于 linuxdeployqt 工具的应用。 ... [详细]
  • 本文介绍了在安装或运行 Python 项目时遇到的 'ModuleNotFoundError: No module named setuptools_rust' 错误,并提供了解决方案。 ... [详细]
  • CentOS7源码编译安装MySQL5.6
    2019独角兽企业重金招聘Python工程师标准一、先在cmake官网下个最新的cmake源码包cmake官网:https:www.cmake.org如此时最新 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 本文详细介绍了如何使用Python编写爬虫程序,从豆瓣电影Top250页面抓取电影信息。文章涵盖了从基础的网页请求到处理反爬虫机制,再到多页数据抓取的全过程,并提供了完整的代码示例。 ... [详细]
  • 解决Linux系统中pygraphviz安装问题
    本文探讨了在Linux环境下安装pygraphviz时遇到的常见问题,并提供了详细的解决方案和最佳实践。 ... [详细]
  • 离线环境下的Python及其第三方库安装指南
    在项目开发中,有时会遇到电脑只能连接内网或完全无法联网的情况。本文将详细介绍如何在这种环境下安装Python及其所需的第三方库,确保开发工作的顺利进行。 ... [详细]
  • 在现代网络环境中,两台计算机之间的文件传输需求日益增长。传统的FTP和SSH方式虽然有效,但其配置复杂、步骤繁琐,难以满足快速且安全的传输需求。本文将介绍一种基于Go语言开发的新一代文件传输工具——Croc,它不仅简化了操作流程,还提供了强大的加密和跨平台支持。 ... [详细]
  • 解决微信电脑版无法刷朋友圈问题:使用安卓远程投屏方案
    在工作期间想要浏览微信和朋友圈却不太方便?虽然微信电脑版目前不支持直接刷朋友圈,但通过远程投屏技术,可以轻松实现在电脑上操作安卓设备的功能。 ... [详细]
  • 从零开始构建完整手机站:Vue CLI 3 实战指南(第一部分)
    本系列教程将引导您使用 Vue CLI 3 构建一个功能齐全的移动应用。我们将深入探讨项目中涉及的每一个知识点,并确保这些内容与实际工作中的需求紧密结合。 ... [详细]
  • 本文详细介绍了如何在ECharts中使用线性渐变色,通过echarts.graphic.LinearGradient方法实现。文章不仅提供了完整的代码示例,还解释了各个参数的具体含义及其应用场景。 ... [详细]
  • 基于KVM的SRIOV直通配置及性能测试
    SRIOV介绍、VF直通配置,以及包转发率性能测试小慢哥的原创文章,欢迎转载目录?1.SRIOV介绍?2.环境说明?3.开启SRIOV?4.生成VF?5.VF ... [详细]
  • Babylon.js 实例展示
    探索 Babylon.js 的强大功能,通过全屏演示体验其卓越性能。本文提供在线文档链接和默认渲染管线的源码调试地址,帮助您深入了解 Babylon.js 的工作原理。 ... [详细]
  • 在Python开发过程中,随着项目数量的增加,不同项目依赖于不同版本的库,容易引发依赖冲突。为了避免这些问题,并保持开发环境的整洁,可以使用Virtualenv和Virtualenvwrapper来创建和管理多个隔离的Python虚拟环境。 ... [详细]
  • Python第三方库安装的多种途径及注意事项
    本文详细介绍了Python第三方库的几种常见安装方法,包括使用pip命令、集成开发环境(如Anaconda)以及手动文件安装,并提供了每种方法的具体操作步骤和适用场景。 ... [详细]
author-avatar
淇蒴_192
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有