从pyqt设计器到exe文件

时间:2017-07-10 04:45:53

标签: python pyqt pyqt5 py2exe qt-designer

我刚刚在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>

1 个答案:

答案 0 :(得分:0)

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

所以这也是一个解决方案

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