【问题标题】:Going from pyqt designer to exe file从 pyqt 设计器到 exe 文件
【发布时间】:2017-12-13 17:00:36
【问题描述】:

我刚刚在 pyqt 的设计器中完成了 .ui 文件的初稿,我想知道如何从 .ui 文件转到 exe 以让某人测试我的 ui ...我目前有一个 makefile将我的 .ui 文件转换为 .py 文件,但现在我想从 .py 转到 .exe

有人知道怎么做吗?我已经下载了 py2exe,但不确定这是否是我想要的...

请假设我要测试的人没有下载 python 并且正在使用 Windows(跨平台更好,但将使用 Windows)

谢谢!

编辑:当我在 test.py(由 test.ui 制作)上运行 py2exe 时

我用 py -3.6 -m py2exe.build_exe test.py

得到

C:\Users\Chris\Desktop\makeExe>py -3.6 -m py2exe.build_exe test.py
Traceback (most recent call last):
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\runpy.py", lin
e 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\runpy.py", lin
e 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\build_exe.py", line 145, in <module>
    main()
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\build_exe.py", line 141, in main
    builder.analyze()
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\runtime.py", line 160, in analyze
    self.mf.import_hook(modname)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 357, in _find_and_load
    self._scan_code(module.__code__, module)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 388, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 417, in _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range

C:\Users\Chris\Desktop\makeExe>

【问题讨论】:

  • 尝试 this question 从 .ui 文件创建 python 文件,然后构建您的可执行文件。
  • 我已经有了从 .ui 到 .py 的方法(如果问题中不清楚的话,我很抱歉),但我不确定如何从 .py 到 .exe,或者如果我什至可以不添加任何额外的代码
  • 查看 this 以获取有关部署 PyQt 应用程序的指导。
  • 试试pyinstaller :P
  • pyinstaller 为我工作!

标签: python pyqt pyqt5 py2exe qt-designer


【解决方案1】:

Py2exe 不支持签名,而 Pyinstaller 支持从 1.4 版本开始签名

所以这也是一种解决方案

pip install pyinstaller
pyinstaller --onefile --windowed test.py

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多