pyinstaller

Python打包成exe文件很难?一分钟即可学会,并添加图标!

你说的曾经没有我的故事 提交于 2020-04-23 10:55:41
环境 1、python 3.7 2、pyinstaller 下载方式: 2.1 python安装(略) 2.2 安装pyinstaller 打开DOS窗口输入以下命令: pip install pyinstaller 打包exe程序 打开DOS窗口,输入命令:pyinstaller -F -w *.py(星号是.py的全部路径) pyinstaller -F -w G:\automation\test.py (备注:-F是打包单一文件,-w是运行时不弹出黑窗口) 如下图显示,打包成功,会显示exe程序的位置,找到运行。 给exe程序添加图标 需要准备一张.ico后缀名的图片(可自行网上下载) 然后使用命令(注意路径) pyinstaller -F -w -i G:\automation\tpian.ico G:\automation\test.py 3 最后需要注意的是,需要移动exe程序的位置,才可以显示图片 常用pyinstaller 命令: 1. -i 给应用程序添加图标 2. -F 指定打包后只生成一个exe格式的文件 3. -D –onedir 创建一个目录,包含exe文件,但会依赖很多文件(默认选项) 4. -c –console, –nowindowed 使用控制台,无界面(默认) 5. -w –windowed, –noconsole 使用窗口,无控制台 6. -p

Pyinstaller (python打包为exe文件)

霸气de小男生 提交于 2020-04-23 10:54:33
需求分析: python脚本如果在没有安装python的机器上不能运行,所以将脚本打包成exe文件,降低脚本对环境的依赖性,同时运行更加迅速。 当然打包的脚本似乎不是在所有的win平台下都能使用,win7有一部分不能使用,我在win10能够很好的运行。 准备: pyinstaller ( http://www.pyinstaller.org ) 首先还是去官网看支持的python版本,不然会很尴尬的。 安装: 需要安装pyinstaller和pywin32 使用以下命令将会自动安装两个包,在cmd用pip命令 方法一: pip install -i https://pypi.douban.com/simple/pyinstaller(豆瓣源) 方法二: pip install pyinstaller(会自动下载future, pywin32, pyinstaller) 运行方式: 1、cmd进入到安装pyinstaller的python环境下的/python/scripts目录 找到pyinstaller.exe。 2、执行命令: pyinstaller.exe -F path:demo.py 案例: 将D:\pythonProject\python3.5\september19\calculator.py文件打为exe可执行文件 # 1

手把手教你使用Python批量创建复工证明

女生的网名这么多〃 提交于 2020-04-23 04:53:09
/1 前言/ 受疫情影响,2020年2月份、3月份企业复工需为员工开具复工证明。因本公司人数较多,复制粘贴工作量巨大,特此为行政同事写此小工具,现与诸位共享。 /2 目标/ 1.实现批量将 Excel 姓名、身份证号信息导入 Word模板,并生成独立的 Word 文档; 2.此方法核心思路是 word 的邮件合并功能,可以理解为邮件合并 Python 版; 3.还可以实现批量在职证明生成、批量工资条生成、批量证书生成等功能。 /3 涉及的库/ mailmerge,pandas /4 具体实现/ 1.制作 Word 模板 首先上成品图,如上图所示,仅红框内为特殊字符,其他均为普通模板文本,下面详细为大家介绍如何生成特殊字符。 按以上操作分别将函数名添加到正确位置,即可生成Word 模板。 2.制作 Excel 模板 在员工信息总表提取数据(可先按需求筛选,如筛选外省员工),保证模板内至少包含姓名、身份证号两列。 两个文件分别以“模板”命名。 3.代码实现 代码非常简单,通过 pandas 读取 Excel 数据,下方mailmerge 用法可理解为固定格式。 4.结果展示 全部选中后批量打印! 5.生成 exe 文件(pyinstaller -F 复工证明批量.py) 简易版为无需导入 Excel 数据,通过 input()直接填入数据,生成文件。 好了,打包发送给行政(人资)

including smartsheet sdk in a bundled app via pyinstaller

流过昼夜 提交于 2020-04-21 19:47:42
问题 I developed a Python 2.7 app using the smartsheet SDK and it works fine on y machine. Then I bundle it into an app via PyInstaller and I get this error when I run it: DEBUG:smartsheet.smartsheet:try loading api class Home DEBUG:smartsheet.smartsheet:try loading model class Home DEBUG:smartsheet.smartsheet:ImportError! Cound not load api or model class Home Exception in Tkinter callback Traceback (most recent call last): File "lib-tk/Tkinter.py", line 1536, in __call__ File "pacers.py", line

PythonGUI:打包Py文件生成exe

雨燕双飞 提交于 2020-04-20 17:08:46
exe文件是所有电脑都能打开的,但是Python生成的就是py文件,没有安装交互解释器的朋友都打不开,而且任何编程语言最后都是要生成为一个exe文件的 首先需要下载一个生成exe的库:pyinstaller 用pip指令:pip install pyinstaller 在Powershell中下载如下,cmd也差不多 注意:下载如果出错,可能是因为拥有多个版本从而注册多个环境变量,所以去环境变量,删掉多余的Script文件夹变量,保留一个 下一步:创建一个测试文件夹。我的如下,名字随便 然后找到一个图标文件,什么图标都可以,必须是.ico文件 放在同一个文件夹中 再次打开终端,用cd指令进入目标文件夹,然后输入(我自己按照我的文件名): pyinstaller -F -i ICON1.ico Button.py 格式就是: pyinstaller -F -i 图标文件 py文件 然后出现如下反应 如果大概是这样,那就成功了,安装失败点击这里 ※ 再次打开文件夹,打开dist文件夹,就有exe了 注意:其他文件夹不要动 生成完就是这个 exe文件 安装失败问题 如果最后一行输出这个 原因:代码不是UTF-8或者Python可以识别的类型,记事本打开这个文件,重新另存为,选择编码为:UTF-8 点赞 3 收藏 分享 文章举报 北极光~ 发布了236 篇原创文章 · 获赞 354 ·

pyinstaller Hidden import not found

 ̄綄美尐妖づ 提交于 2020-04-16 05:51:30
问题 I'm using pyinstaller. In my script there is: import toml config = toml.load('config.toml') I compiled my script with: pyinstaller main.py --onefile --clean --name myApp but when I run the executable it gave me: ModuleNotFoundError: No module named 'toml' So I tried this: pyinstaller main.py --hidden-import toml --onefile --clean --name myApp and now pyinstaller says: ERROR: Hidden import 'toml' not found 回答1: Found the answer. If you are using a virtual environment (Like Pipenv, pyenv, venv)

Why does my tkinter app will show a node.js window?

会有一股神秘感。 提交于 2020-04-16 05:13:11
问题 I use pyinstaller to pack a .py file. Then when I use something about web crawler (I use requests module). This window will show and disappear fastly. I want to say that it is maybe incredible.It wouldn't pop this window when I run this .py file,but after using pyinstaller to pack it,it will pop this window. (In another computer,it doesn't install node.js .And it doesn't pop this window) Here is the module I use: from pynput import keyboard from PIL import Image, ImageTk import ctypes from io

Pyinstaller use --add-binary and --onefile

守給你的承諾、 提交于 2020-04-16 04:03:08
问题 In my project folder I've another folder ('hooks') where I put the dll files. With the following command everything works correctly: pyinstaller --add-binary="hooks;." main.py How can I add the --onefile option? I've already tried pyinstaller --onefile --add-binary="hooks;." main.py , but the .exe can't find my dll files Thank you 来源: https://stackoverflow.com/questions/61009315/pyinstaller-use-add-binary-and-onefile

Pyinstaller use --add-binary and --onefile

我只是一个虾纸丫 提交于 2020-04-16 04:02:34
问题 In my project folder I've another folder ('hooks') where I put the dll files. With the following command everything works correctly: pyinstaller --add-binary="hooks;." main.py How can I add the --onefile option? I've already tried pyinstaller --onefile --add-binary="hooks;." main.py , but the .exe can't find my dll files Thank you 来源: https://stackoverflow.com/questions/61009315/pyinstaller-use-add-binary-and-onefile

ImportError: DLL load failed: The specified module could not be found _ on a different machine (pyinstaller)

天涯浪子 提交于 2020-04-16 04:02:10
问题 I was able to get exe file from py using pyinstaller. I used the following code: pyinstaller -y -F --additional-hooks-dir=. --add-binary ibm_db_dlls;.\ibm_db_dlls Data_QC_Ver1.py this work fine on my laptop, however when trying it on a different machine I get the following error: 回答1: Before I go further into my suggestion an answer in a stack overflow question (see below) that I found was to make sure you have installed pyinstaller and Pywin32 This answer refers to an alternative to