一、前言

python文件打包,将.py文件转化成.exe文件(windows平台),可以使用Pyinstaller来打包

Pyinstaller可以在全平台下使用,但是请注意打包生成的文件不能在全平台使用,需要在不同平台下打对应的包

二、Pyinstaller安装

使用pip可以很方便的安装Pyinstaller

pip installer Pyinstaller

如果没有安装pip,可以先安装pip,pip安装参考https://blog.csdn.net/liuchunming033/article/details/39578019

三、Pyinstaller使用

Pyinstaller将.py文件打包很便捷,只需要一条指令即可;这里的测试文件为test.py

Pyinstaller test.py

这种方式打包会生成一个文件夹,运行的时候会有一个console窗口

打包生成单文件可以在指令中加上-F 或者 --onefile

打包生成单文件程序的启动速度会很慢,尤其是调用了GUI界面的时候;

程序会在所有模块都加载完成后再显示GUI界面,可以使用--onedir打包生成一个文件夹,但是启动速度有明显改善。

Pyinstaller -F test.py
//或者
Pyinstaller test.py --onefile

打包生成的exe文件运行的时候不带console窗口

Pyinstaller -W test.py
//或者
pyinstaller test.py --noconsole

打包生成的图标默认使用的是python的图标,使用自己的图标可以用 -I来设置自己想要的图标

Pyinstaller test.py -i ico.ico

我的参考:https://iassas.com/archives/2329ebda.html

python使用Pyinstaller打包的更多相关文章

  1. python用pyinstaller打包成exe文件

    版本为Python2.7 一.安装Pyinstaller 1.安装pywin32 下载安装文件:查找到跟自己适用的python版本及window系统版本匹配的pywin32,下载后安装  使用pip命 ...

  2. 【Python】pyinstaller打包运行报错failed to execute script main

    前言 最近用pyinstaller打包的时候一直报"failed to execute script main". 最终使用"pyinstaller --hidden-i ...

  3. python 使用pyinstaller打包程序

    使用pyinstaller 打包.py脚本,在其他计算机可以直接运行,不需要python环境 安装pyinstaller库 pip install pystaller 打包程序 pyinstaller ...

  4. Python | 用Pyinstaller打包发布exe应用

    参考:https://jingyan.baidu.com/article/a378c960b47034b3282830bb.html https://ask.csdn.net/questions/72 ...

  5. python pyinstaller 打包exe报错

    今天用python 使用pyinstaller打包exe出现错误 环境pyqt5 + python3.6 在导入pyqt5包之前加上如下代码 import sysimport osif hasattr ...

  6. 利用PyInstaller打包exe文件

    前言 平常我们通过Python写完一些小脚本之后,如果使用不频繁的话,一般会选择在DOS界面直接跑脚本,或者在IDE中运行.但当我们需要频繁使用某些脚本,或者在没有Python环境的机器上也能顺利运行 ...

  7. [python学习笔记] pyinstaller打包pyqt5程序无法运行

    问题 pyinstaller打包的pyqt5程序在部分电脑上会失败.用户截图提示下边错误日志 无法定位程序输入点 ucrtbase.terminate 于动态链接库 api-ms-win-crt-ru ...

  8. win10环境下利用pyinstaller把python代码(.py)打包成可执行文件(.exe)

    前言 最近写了一个小小的检测程序,python写起来只需要短短一百行,可是打包起来就没有C那么容易了.下面记录一下我艰难的"打包"过程. 方法一:py2exe py2exe是一种经 ...

  9. PyInstaller 打包 python程序成exe

    pychaim下PyInstaller 打包 python程序 主题是使用PyInstaller 打包python时遇到一些问题以及解决方案,其中将要打包的程序是用tensorflow做的LSTM算法 ...

随机推荐

  1. 【Mac】 /usr/local 文件夹权限问题

    修改文件夹权限 sudo chown -R $(whoami) /usr/local/ 如果失败提示Operation not permitted 或其他权限不足,则需要关闭Rootless Root ...

  2. Gson反序列json到实体类

    gson在基准测试过程中各项性能接近于Jackson(具体可以看Benchmark of Java JSON libraries)里面的测试, 本人亲测过,实测结果与他的数据一致,Jackson安全性 ...

  3. [ kvm ] 学习笔记 2:虚拟化基础

    1. 虚拟化概念 什么是虚拟化 虚拟化是使用所谓虚拟机管理程序从一台物理机上创建若干个虚拟机的过程.虚拟机的行为和运转方式与物理机一样,但它们会使用物理机的计算资源,如 CPU .内存和存储.虚拟机管 ...

  4. 【端口转发】k8s port-forward端口转发 和 ssh -NfL端口转发

    kubectl port-forward端口转发 将远程pod端口转发到本地端口 kubectl port-forward monitoring-grafana-695c545f46-rhtwc -- ...

  5. elasticsearch in语句和not in语句

    sql语句示例: select * from table where t_id in (1,2,3,4) php代码示例: $search_query = [ "bool" =&g ...

  6. 【Leetcode_easy】989. Add to Array-Form of Integer

    problem 989. Add to Array-Form of Integer 参考 1. Leetcode_easy_989. Add to Array-Form of Integer; 完

  7. WEUI switch 如何取值?

    let id = $(this).attr("id"); let name = $(this).attr("data-name"); HTML: <div ...

  8. RobotFramework: 获取当前时间戳

    robot中先导入DateTime库 #获取当前时间:2019-07-31 10:46:29.940 ${time} Get Current Date result_format=timestamp ...

  9. github账户初始化设置

    1.首先在github官网https://github.com/上注册自己的账户: 2.去git官网https://git-scm.com/downloads,根据电脑系统下载合适的版本并安装. 3. ...

  10. python字符串/列表/元组/字典之间的相互转换(5)

    一.字符串str与列表list 1.字符串转列表 字符串转为列表list,可以使用str.split()方法,split方法是在字符串中对指定字符进行切片,并返回一个列表,示例代码如下: # !usr ...