使用pyinstaller打包pyqt5出错问题解决

原文链接

我使用的打包命令如下
pyinstaller -F form.py
打包的时候有很多lib not found的警告,打包完运行会出错,提示如下

C:\Users\leon\Desktop\pyqt\dist>form.exe
Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_qt5plugins.py", line 46, in <module>
  File "c:\users\leon\appdata\local\programs\python\python35\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 573, in load_module
    module = loader.load_module(fullname)
ImportError: DLL load failed: 找不到指定的模块。
Failed to execute script pyi_rth_qt5plugins

找了下是路径不对,指定搜索路径就好了,如下
pyinstaller --path C:\Users\leon\AppData\Local\Programs\Python\Python35\Lib\site-packages\PyQt5\Qt\bin -F form.py

双击form.exe运行时GUI界面正常运行,但还有控制台显示在哪儿,可以加--noconsole参数去掉控制台
pyinstaller --path C:\Users\leon\AppData\Local\Programs\Python\Python35\Lib\site-packages\PyQt5\Qt\bin -F form.py --noconsole

PyInstaller打包python脚本时出错

03-24

D:\PyInstaller-3.2.1>python pyinstaller.py -F E:\Pywork\myapp\test.pyrn497 INFO: PyInstaller: 3.2.1rn498 INFO: Python: 3.6.0rn499 INFO: Platform: Windows-10-10.0.14393-SP0rn501 INFO: wrote D:\PyInstaller-3.2.1\test\test.specrn503 INFO: UPX is not available.rn506 INFO: Extending PYTHONPATH with pathsrn['E:\\Pywork\\myapp', 'D:\\PyInstaller-3.2.1\\test']rn508 INFO: checking Analysisrn509 INFO: Building Analysis because out00-Analysis.toc is non existentrn510 INFO: Initializing module dependency graph...rn513 INFO: Initializing module graph hooks...rn559 INFO: Analyzing base_library.zip ...rnTraceback (most recent call last):rn File "pyinstaller.py", line 15, in rn run()rn File "D:\PyInstaller-3.2.1\PyInstaller\__main__.py", line 90, in runrn run_build(pyi_config, spec_file, **vars(args))rn File "D:\PyInstaller-3.2.1\PyInstaller\__main__.py", line 46, in run_buildrn PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)rn File "D:\PyInstaller-3.2.1\PyInstaller\building\build_main.py", line 788, in mainrn build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))rn File "D:\PyInstaller-3.2.1\PyInstaller\building\build_main.py", line 734, in buildrn exec(text, spec_namespace)rn File "", line 16, in rn File "D:\PyInstaller-3.2.1\PyInstaller\building\build_main.py", line 212, in __init__rn self.__postinit__()rn File "D:\PyInstaller-3.2.1\PyInstaller\building\datastruct.py", line 161, in __postinit__rn self.assemble()rn File "D:\PyInstaller-3.2.1\PyInstaller\building\build_main.py", line 317, in assemblern excludes=self.excludes, user_hook_dirs=self.hookspath)rn File "D:\PyInstaller-3.2.1\PyInstaller\depend\analysis.py", line 560, in initialize_modgraphrn graph.import_hook(m)rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hookrn source_package, target_module_partname, level)rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_packagern target_module_headname, target_package_name, source_package)rn File "D:\PyInstaller-3.2.1\PyInstaller\depend\analysis.py", line 209, in _safe_import_modulern module_basename, module_name, parent_package)rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_modulern module_name, file_handle, pathname, metadata)rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_modulern self._scan_code(m, co, co_ast)rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_codern module, module_code_object, is_scanning_imports=False)rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecodern global_attr_name = get_operation_arg_name()rn File "D:\PyInstaller-3.2.1\PyInstaller\lib\modulegraph\modulegraph.py", line 2731, in get_operation_arg_namern return module_code_object.co_names[co_names_index]rnIndexError: tuple index out of rangernrnrnrn大神们这种错误该如何解决呀

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试