问题标签 [pyinstaller]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 分发 Python 应用程序
快速提问...一旦我使用 wx gui 等构建了一个 .py 应用程序...我可以使用 pyinstaller 或 cx_freeze 编译它,并将二进制文件发送到我的服务器,对吗?
这是分发脚本的好方法吗?我对应用程序开发周期相当陌生......我有一些我想公开的python脚本,因为它们让我的生活更轻松......
如果您要与社区的其他人共享一些代码,向人们提供 .py 代码,并且还想分发二进制文件,您会使用 pyinstaller 和 cx_freeze 编译 .py,还是使用其他方法?
开发环境目前是 Mac OSX,和一个 debian domU....
谢谢!
python - Python EXE(pyinstaller)和动态导入的重新加载目录
我已经使用 pyinstaller 创建了一个 wxPython(不确定它是否相关)可执行文件,它具有从sys.path.append
在代码中添加的目录加载和执行 python 脚本的特定任务。在执行过程中,应用程序可以很好地查看和导入目录的内容。但是,如果将文件添加到此目录,应用程序将尝试导入它并失败,并指出没有该名称的模块。必须重新启动应用程序才能加载新模块。正在使用该import
语句动态导入文件。
有没有办法解决这个问题?如果应用程序未编译,则导入工作正常。
python - pyinstaller seems not to find a data file
Edit 3: I replaced __file__
with sys.argv[0]
, when I need to know the location of my script/executable. This is not exactly the same, but in my case it seems to run fine (at least on executable version...). Now everything is working fine, in one-file mode, with use of accepted answer's function to access resource files!
Edit 2: as shown in accepted answer's comments, problem is coming from path resolution in my script; I try to use __file__
to get the location of the script, so that I can access to its resource files. This does not work once packaged, as __file__
will return filename from Python.dll
to the script, so quite always no path and just a file name. So I have to find another trick to make access to resource files; a work-around for the moment is to move current directory to the executable path.
By the way, this means that the ConfigParser should report problem when accessing the file, and not that a section is missing.
I'll update this question with the way I resolved this path resolution question.
I've got problems with pyinstaller
, and as it's the first time I'm using it, it's sure that I've done something wrong.
So, here's the problem: pyisntaller
runs smoothly on a script I wrote, and generates some stuff in dist
folder. Ok, so now I want to execute it to see if all went well, and here's what I get:
My first idea was that the logging.conf
file was missing, so I added it (and some other resource files) in the p_tool.spec
file, but this is not better.
Python version: 2.6.6, under WinXP. I'm using pyinstaller
as I will need it to package files for a Solaris workstation.
So, anyone did have this problem? The only topic related is the following question: PyInstaller Problem, really close to my problem, but hopelessly it got no answer.
Edit3: details about logging removed, as not really related to the problem.
python - 将python代码编译成单个exe
我一直在尝试将 python 代码编译成单个 exe,但我没能正确地做到这一点。
我试过 pyinstaller,这是 .spec 文件:
Pyinstaller 编译得很好,创建了一个可以工作的单个 exe 文件,但显然其他没有安装相同版本的 python(2.7.2)的用户无法运行它。没有给出任何错误,它根本不会启动。我已经通过发送给几个朋友进行了尝试,并在虚拟机上进行了尝试。
试过py2exe。当涉及到编译(旁边的所有库以及其余文件)时,它工作正常。我尝试将其编译为单个文件,但编译后的 exe 文件给了我一个“toolbox.exe 已停止工作”错误。这是错误报告,以防万一,可能有用:
setup.py 文件是:
这是single.py:
/li>
我编写的程序使用 tkinter、sys、random 和 win32clipboard(pywin) 模块。我究竟做错了什么?还有其他更好的编译器吗?
更新:根据 Joël 的提示,我使用调试和控制台模式编译。仍然不适用于没有 python 2.7 的用户。这是错误消息:
我真的希望这可以为可能的答案提供帮助。
python - Pyinstaller 不工作
我试图使用 Pyinstaller 创建一个独立的可执行文件。从配置到 Makespec 部分的过程很顺利。但是在处理 Build.py 时,显示了以下错误。
我正在使用 Tkinter。这是否会产生任何问题。如果 Pyinstaller 不起作用,这是另一种可用的替代方法
我在使用 Makespec.py 的 -K 选项并使用 Build.py 跟进后得到的错误消息是
python - 尝试构建 --onefile 时 PyQt 出现 PyInstaller 错误
我正在尝试使用 PyInstaller 1.5 编译 PyQt 程序。当我使用 --onedir (默认值)时,以下两个程序对我来说都很好,但这会创建相当大的程序。我想使用 --onefile 选项,但是当我运行创建的 onefile 应用程序时,出现错误:
此错误发生在这两个方面:
还有这个:
有没有人有任何想法?
python - PyQt 和 pyinstaller:无法加载 QIcon
我正在尝试编译我的第一个使用 PyQt 的应用程序。它编译成功,但如果我尝试运行,它会说:
它说原始错误在哪里。它在我设置图标的地方:
如您所见,我从资源模块导入图标,该图标是使用 qrc 文件中的 pyrcc4.exe 生成的。原始 qrc 文件包含这样的信息:
Python 模块生成成功,原始脚本运行良好。我做错了吗?
python - 使用 pyinstaller 构建图像和一些配置文件,例如 txt 和 xml 文件
在将图像和 txt 等数据文件添加到 python 程序时,我遇到了 pyinstaller 的问题。例如,我创建了一个带有图标的工具栏,并将它们存储在一个名为 images 的单独文件夹中。我还有一些 txt 和 xml 文件来存储一些配置。这些 txt ant xml 文件存储在另一个名为 data_files 的文件夹中。所有 py 文件都存储在另一个名为 source 的文件夹中。
当我尝试使用 pyinstaller 构建这个 python 程序时,pyinstaller 可以成功构建所有源文件夹,但无法构建 images 和 data_files 文件夹。我检查了 pyinstaller 的文档,但找不到任何解决方案。我做了很多谷歌搜索,发现只有这个资源有帮助,但这是一个非常不足的资源。
我的主要问题是:如何使用 pyinstaller 使用单独构建的文件夹(例如 images 和 confs)构建 exe 文件?
编辑: 我找到了解决方案。创建规范文件时,您必须使用a.datas参数。
上面的规范代码是为我的项目设计的。正如在这个规范代码中看到的,我已经包含了 3 个用 python 程序构建的图标。生成程序时,会有一个独立的可执行文件,其中嵌入了这些图标。
但是如果我们有这么多文件怎么办?假设我们的程序中有 1000 个图标要使用。手动写到规范文件是非常不合适的。必须有一个循环系统来读取文件目录并动态添加这些文件。但我找不到如何动态添加这些文件。我认为没有任何机会手动添加这么多文件。如果有人知道请分享。
python - 在 PyInstaller 中打包多个脚本
我正在使用 PyInstaller 将两个脚本转换为一个可执行文件,其中一个调用另一个。我遇到的问题是我无法弄清楚如何捆绑这两个脚本并仍然让它们相互引用:
导致问题的代码是一个脚本,script1.py
包含:
当我正常运行脚本时,这工作正常,但是一旦它们被打包到 PyInstaller 中,我不知道如何使调用工作。
python - 使用 Pyinstaller 编译 PyQt4 时出错
过去,我使用 pycompiler(或“pyinstaller”)将使用 PyQt4 框架的程序编译为可执行代码,仅仅是因为 py2exe.
我最近换了电脑,还没有设法在上面编译我的 PyQt4 程序!
在这台计算机上,我设置了一个环境变量 %pycompile% ,其中包含 pyinstaller.py 文件的目录。
这是我插入 cmd.exe 的代码,它使用 Python 代码 NOT IMPORT PYQT4。
但是,当我尝试编译基于 PyQt4 的程序时,在尝试编译 PyQt4 程序时,我得到一个源自 pyinstaller.py 导入的 python 文件内部的语法错误(根据我的解释)。“执行_ =执行”
我正在使用与旧计算机上相同的 pycompile 版本(216)。它们都运行 32 位 Windows 和 32 位 python 2.7.2。
所有的帮助都想要!
(我吓坏了我的 MASSIVE 编程项目无法编译!)
我已经阅读了很多关于 PyQt 的 pyinstaller 错误的 Stack 问题,但不是我的特定错误!
谢谢!
我的代码以:
并以:
python 2.7.2(32位)
pycompile build(216)
PyQt4(4.5)
Windows 7(32位)