热门标签 | 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



推荐阅读
  • 本文介绍了计算机网络的定义和通信流程,包括客户端编译文件、二进制转换、三层路由设备等。同时,还介绍了计算机网络中常用的关键词,如MAC地址和IP地址。 ... [详细]
  • 安装mysqlclient失败解决办法
    本文介绍了在MAC系统中,使用django使用mysql数据库报错的解决办法。通过源码安装mysqlclient或将mysql_config添加到系统环境变量中,可以解决安装mysqlclient失败的问题。同时,还介绍了查看mysql安装路径和使配置文件生效的方法。 ... [详细]
  • 在Kubernetes上部署JupyterHub的步骤和实验依赖
    本文介绍了在Kubernetes上部署JupyterHub的步骤和实验所需的依赖,包括安装Docker和K8s,使用kubeadm进行安装,以及更新下载的镜像等。 ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • 本文介绍了Python高级网络编程及TCP/IP协议簇的OSI七层模型。首先简单介绍了七层模型的各层及其封装解封装过程。然后讨论了程序开发中涉及到的网络通信内容,主要包括TCP协议、UDP协议和IPV4协议。最后还介绍了socket编程、聊天socket实现、远程执行命令、上传文件、socketserver及其源码分析等相关内容。 ... [详细]
  • 本文介绍了在Python3中如何使用选择文件对话框的格式打开和保存图片的方法。通过使用tkinter库中的filedialog模块的asksaveasfilename和askopenfilename函数,可以方便地选择要打开或保存的图片文件,并进行相关操作。具体的代码示例和操作步骤也被提供。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • Firefox火狐浏览器关闭到http://detectportal.firefox.com的流量问题解决办法
    本文介绍了使用Firefox火狐浏览器时出现关闭到http://detectportal.firefox.com的流量问题,并提供了解决办法。问题的本质是因为火狐默认开启了Captive portal技术,当连接需要认证的WiFi时,火狐会跳出认证界面。通过修改about:config中的network.captive-portal-service.en的值为false,可以解决该问题。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • FeatureRequestIsyourfeaturerequestrelatedtoaproblem?Please ... [详细]
  • Oracle10g备份导入的方法及注意事项
    本文介绍了使用Oracle10g进行备份导入的方法及相关注意事项,同时还介绍了2019年独角兽企业重金招聘Python工程师的标准。内容包括导出exp命令、删用户、创建数据库、授权等操作,以及导入imp命令的使用。详细介绍了导入时的参数设置,如full、ignore、buffer、commit、feedback等。转载来源于https://my.oschina.net/u/1767754/blog/377593。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
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社区 版权所有