community icon indicating copy to clipboard operation
community copied to clipboard

Building Kivy Python executable with pyinstaller is failing

Open weaved459 opened this issue 1 year ago • 8 comments

Env(virtual environment):

OS Ubuntu 22.04.4 Python 3.12.4 Kivy 2.3.0 pyinstaller 6.10.0

pyinstaller main.py results in multiple warnings with a last failure message stating....

AttributeError: module 'PyInstaller.depend.bindepend' has no attribute 'selectImports'

Originally I posted the above under pyinstaller bug reports and got 2 responses.....

One was totally unhelpful and dismissive blaming Kivy and it's hooks. The other did offer a possible fix with the following:

maltfield@host pyinstaller_hooks % diff init.py.old init.py 81c81,87 < from PyInstaller.depend import bindepend

#from PyInstaller.depend import bindepend try: # Pyinstaller >= 6 from PyInstaller.depend.bindepend import get_imports except ImportError: # Pyinstaller < 6 from PyInstaller.depend.bindepend import selectImports as get_imports 370c376,377 < plugin_deps = bindepend.selectImports(plugin_filepath)


    #plugin_deps = bindepend.selectImports(plugin_filepath)
    plugin_deps = get_imports(plugin_filepath)

maltfield@host pyinstaller_hooks %

I modified the python_hooks script and was able to compile cleanly producing a executable but when I attempted to run the executable from a separate directory with _internal and the database (sqlite3) copied to it fails to start stating the follow:

[CRITICAL] [APPLICATION] No window is created. Terminating application run.

weaved459 avatar Aug 16 '24 15:08 weaved459

Can you build a basic hello world app with Kivy? If not you can try: https://kivyschool.com/pyinstaller-instructions/#step-1-have-a-working-kivy-app-to-package

Can you do a minimal runnable example with all your requirements so I can check it out?

AccelQuasarDragon avatar Aug 18 '24 03:08 AccelQuasarDragon

Hi

I use pip to install modules in my virtual environment which is venv much like what pycharm does. (python3.12 -m venv venv, listed at top)

Pyinstaller is installed under that environment and enabled during attempt.

Stripped out all KivyMD so the application is simpler and now opens a main screen that shows an image / label and checks its database to ensure it exists, has data in it. As it checks the database the label's text is updated showing progress until finished.

Appreciate the help and or suggestions greatly !

(venv)virtual_dir$ pyinstaller main.py

99 INFO: PyInstaller: 6.10.0, contrib hooks: 2024.8 99 INFO: Python: 3.12.4 101 INFO: Platform: Linux-6.8.0-40-generic-x86_64-with-glibc2.35 101 INFO: Python environment: /home/weave/Python_Work/CanDoIt(kivy only)/venv 101 INFO: wrote /home/weave/Python_Work/CanDoIt(kivy only)/main.spec 103 INFO: Module search paths (PYTHONPATH): ['/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages', '/home/weave/Python_Work/CanDoIt(kivy ' 'only)/venv/lib/python3.12/site-packages/setuptools/_vendor', '/home/weave/Python_Work/CanDoIt(kivy only)'] 236 INFO: checking Analysis 236 INFO: Building Analysis because Analysis-00.toc is non existent 236 INFO: Running Analysis Analysis-00.toc 236 INFO: Target bytecode optimization level: 0 236 INFO: Initializing module dependency graph... 254 INFO: Caching module graph hooks... 271 INFO: Analyzing base_library.zip ... 1375 INFO: Processing standard module hook 'hook-heapq.py' from '/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/hooks' 1514 INFO: Processing standard module hook 'hook-encodings.py' from '/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/hooks' 4078 INFO: Processing standard module hook 'hook-pickle.py' from '/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/hooks' 6048 INFO: Caching module dependency graph... 6162 INFO: Looking for Python shared library... 6245 INFO: Using Python shared library: /lib/x86_64-linux-gnu/libpython3.12.so 6245 INFO: Analyzing /home/weave/Python_Work/CanDoIt(kivy only)/main.py 6268 INFO: Processing standard module hook 'hook-kivy.py' from '/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/hooks' 6275 INFO: Kivy: v2.3.0 6275 INFO: Logger: Record log in /home/weave/.kivy/logs/kivy_24-08-18_1.txt [INFO ] [Logger ] Record log in /home/weave/.kivy/logs/kivy_24-08-18_1.txt [INFO ] [Kivy ] v2.3.0 6275 INFO: Kivy: Installed at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/init.py" [INFO ] [Kivy ] Installed at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/init.py" 6275 INFO: Python: v3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] [INFO ] [Python ] v3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] 6275 INFO: Python: Interpreter at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/python3.12" [INFO ] [Python ] Interpreter at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/python3.12" 6276 INFO: Logger: Purge log fired. Processing... [INFO ] [Logger ] Purge log fired. Processing... 6277 INFO: Logger: Purge finished! [INFO ] [Logger ] Purge finished! 6280 INFO: Factory: 195 symbols loaded [INFO ] [Factory ] 195 symbols loaded 6280 DEBUG: Collecting submodules for kivy.graphics [DEBUG ] Collecting submodules for kivy.graphics [INFO ] [Logger ] Record log in /home/weave/.kivy/logs/kivy_24-08-18_2.txt [INFO ] [Kivy ] v2.3.0 [INFO ] [Kivy ] Installed at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/init.py" [INFO ] [Python ] v3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] [INFO ] [Python ] Interpreter at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/python3.12" [INFO ] [Logger ] Purge log fired. Processing... [INFO ] [Logger ] Purge finished! 73 INFO: Kivy: v2.3.0 74 INFO: Logger: Record log in /home/weave/.kivy/logs/kivy_24-08-18_3.txt [INFO ] [Logger ] Record log in /home/weave/.kivy/logs/kivy_24-08-18_3.txt [INFO ] [Kivy ] v2.3.0 74 INFO: Kivy: Installed at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/init.py" [INFO ] [Kivy ] Installed at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/init.py" 74 INFO: Python: v3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] [INFO ] [Python ] v3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] 74 INFO: Python: Interpreter at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/python3.12" [INFO ] [Python ] Interpreter at "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/python3.12" 74 INFO: Logger: Purge log fired. Processing... [INFO ] [Logger ] Purge log fired. Processing... 76 INFO: Logger: Purge finished! [INFO ] [Logger ] Purge finished! 119 INFO: Image: Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored) [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored) 126 DEBUG: collect_submodules - scanning (sub)package kivy.graphics in location(s): ['/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/graphics'] [DEBUG ] [collect_submodules - scanning (sub)package kivy.graphics in location(s)] ['/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/graphics'] 127 DEBUG: collect_submodules - scanning (sub)package kivy.graphics.cgl_backend [DEBUG ] collect_submodules - scanning (sub)package kivy.graphics.cgl_backend 127 DEBUG: collect_submodules - scanning (sub)package kivy.graphics.cgl_backend in location(s): ['/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/graphics/cgl_backend'] [DEBUG ] [collect_submodules - scanning (sub)package kivy.graphics.cgl_backend in location(s)] ['/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/graphics/cgl_backend'] 6665 DEBUG: collect_submodules - found submodules: ['kivy.graphics', 'kivy.graphics.boxshadow', 'kivy.graphics.buffer', 'kivy.graphics.cgl', 'kivy.graphics.cgl_backend', 'kivy.graphics.cgl_backend.cgl_debug', 'kivy.graphics.cgl_backend.cgl_gl', 'kivy.graphics.cgl_backend.cgl_glew', 'kivy.graphics.cgl_backend.cgl_mock', 'kivy.graphics.cgl_backend.cgl_sdl2', 'kivy.graphics.compiler', 'kivy.graphics.context', 'kivy.graphics.context_instructions', 'kivy.graphics.fbo', 'kivy.graphics.gl_instructions', 'kivy.graphics.instructions', 'kivy.graphics.opengl', 'kivy.graphics.opengl_utils', 'kivy.graphics.scissor_instructions', 'kivy.graphics.shader', 'kivy.graphics.stencil_instructions', 'kivy.graphics.svg', 'kivy.graphics.tesselator', 'kivy.graphics.texture', 'kivy.graphics.transformation', 'kivy.graphics.vbo', 'kivy.graphics.vertex', 'kivy.graphics.vertex_instructions'] [DEBUG ] [collect_submodules - found submodules] ['kivy.graphics', 'kivy.graphics.boxshadow', 'kivy.graphics.buffer', 'kivy.graphics.cgl', 'kivy.graphics.cgl_backend', 'kivy.graphics.cgl_backend.cgl_debug', 'kivy.graphics.cgl_backend.cgl_gl', 'kivy.graphics.cgl_backend.cgl_glew', 'kivy.graphics.cgl_backend.cgl_mock', 'kivy.graphics.cgl_backend.cgl_sdl2', 'kivy.graphics.compiler', 'kivy.graphics.context', 'kivy.graphics.context_instructions', 'kivy.graphics.fbo', 'kivy.graphics.gl_instructions', 'kivy.graphics.instructions', 'kivy.graphics.opengl', 'kivy.graphics.opengl_utils', 'kivy.graphics.scissor_instructions', 'kivy.graphics.shader', 'kivy.graphics.stencil_instructions', 'kivy.graphics.svg', 'kivy.graphics.tesselator', 'kivy.graphics.texture', 'kivy.graphics.transformation', 'kivy.graphics.vbo', 'kivy.graphics.vertex', 'kivy.graphics.vertex_instructions'] 6693 WARNING: stderr: Traceback (most recent call last): Traceback (most recent call last): 6693 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/pyinstaller", line 10, in File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/bin/pyinstaller", line 10, in 6693 WARNING: stderr: sys.exit(_console_script_run()) sys.exit(_console_script_run()) 6693 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ 6694 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 231, in _console_script_run File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 231, in _console_script_run 6694 WARNING: stderr: run() run() 6694 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 215, in run File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 215, in run 6694 WARNING: stderr: run_build(pyi_config, spec_file, **vars(args)) run_build(pyi_config, spec_file, **vars(args)) 6695 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 70, in run_build File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 70, in run_build 6695 WARNING: stderr: PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) 6695 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1227, in main File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1227, in main 6696 WARNING: stderr: build(specfile, distpath, workpath, clean_build) build(specfile, distpath, workpath, clean_build) 6696 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1167, in build File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1167, in build 6697 WARNING: stderr: exec(code, spec_namespace) exec(code, spec_namespace) 6697 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/main.spec", line 4, in File "/home/weave/Python_Work/CanDoIt(kivy only)/main.spec", line 4, in 6698 WARNING: stderr: a = Analysis( a = Analysis( 6698 WARNING: stderr: ^^^^^^^^^ ^^^^^^^^^ 6698 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 558, in init File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 558, in init 6699 WARNING: stderr: self.postinit() self.postinit() 6699 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/datastruct.py", line 184, in postinit File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/datastruct.py", line 184, in postinit 6699 WARNING: stderr: self.assemble() self.assemble() 6699 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 698, in assemble File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 698, in assemble 6700 WARNING: stderr: program_scripts.append(self.graph.add_script(script)) program_scripts.append(self.graph.add_script(script)) 6700 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6700 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 268, in add_script File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 268, in add_script 6701 WARNING: stderr: self._top_script_node = super().add_script(pathname) self._top_script_node = super().add_script(pathname) 6701 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6701 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1177, in add_script File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1177, in add_script 6702 WARNING: stderr: self._process_imports(n) self._process_imports(n) 6702 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports 6703 WARNING: stderr: target_modules = self._safe_import_hook(*import_info, **kwargs) target_modules = self._safe_import_hook(*import_info, **kwargs) 6703 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6703 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 437, in _safe_import_hook File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 437, in _safe_import_hook 6704 WARNING: stderr: ret_modules = super()._safe_import_hook( ret_modules = super()._safe_import_hook( 6704 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6704 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2065, in _safe_import_hook File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2065, in _safe_import_hook 6705 WARNING: stderr: target_modules = self.import_hook( target_modules = self.import_hook( 6705 WARNING: stderr: ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ 6705 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1249, in import_hook File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1249, in import_hook 6706 WARNING: stderr: target_package, target_module_partname = self._find_head_package( target_package, target_module_partname = self._find_head_package( 6706 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ 6706 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1428, in _find_head_package File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1428, in _find_head_package 6707 WARNING: stderr: target_package = self._safe_import_module( target_package = self._safe_import_module( 6707 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ 6708 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 502, in _safe_import_module File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 502, in _safe_import_module 6708 WARNING: stderr: return super()._safe_import_module(module_basename, module_name, parent_package) return super()._safe_import_module(module_basename, module_name, parent_package) 6708 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6708 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1809, in _safe_import_module File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1809, in _safe_import_module 6709 WARNING: stderr: self._process_imports(n) self._process_imports(n) 6709 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports 6711 WARNING: stderr: target_modules = self._safe_import_hook(*import_info, **kwargs) target_modules = self._safe_import_hook(*import_info, **kwargs) 6711 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6711 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 368, in _safe_import_hook File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 368, in _safe_import_hook 6711 WARNING: stderr: excluded_imports = self._find_all_excluded_imports(source_module.identifier) excluded_imports = self._find_all_excluded_imports(source_module.identifier) 6712 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6712 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 356, in _find_all_excluded_imports File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 356, in _find_all_excluded_imports 6712 WARNING: stderr: excluded_imports.update(module_hook.excludedimports) excluded_imports.update(module_hook.excludedimports) 6713 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6713 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 316, in getattr File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 316, in getattr 6713 WARNING: stderr: self._load_hook_module() self._load_hook_module() 6713 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 383, in _load_hook_module File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 383, in _load_hook_module 6714 WARNING: stderr: self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename) self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename) 6714 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6714 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/compat.py", line 610, in importlib_load_source File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/compat.py", line 610, in importlib_load_source 6715 WARNING: stderr: mod_loader.exec_module(mod) mod_loader.exec_module(mod) 6715 WARNING: stderr: File "", line 995, in exec_module File "", line 995, in exec_module 6715 WARNING: stderr: File "", line 488, in _call_with_frames_removed File "", line 488, in _call_with_frames_removed 6715 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py", line 21, in File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py", line 21, in 6716 WARNING: stderr: hiddenimports = get_deps_all()['hiddenimports'] hiddenimports = get_deps_all()['hiddenimports'] 6716 WARNING: stderr: ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ 6716 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 272, in get_deps_all File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 272, in get_deps_all 6716 WARNING: stderr: 'binaries': _find_gst_binaries(), 'binaries': _find_gst_binaries(), 6717 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ 6717 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 370, in _find_gst_binaries File "/home/weave/Python_Work/CanDoIt(kivy only)/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 370, in _find_gst_binaries 6717 WARNING: stderr: plugin_deps = bindepend.selectImports(plugin_filepath) plugin_deps = bindepend.selectImports(plugin_filepath) 6718 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ 6718 WARNING: stderr: AttributeError: module 'PyInstaller.depend.bindepend' has no attribute 'selectImports' AttributeError: module 'PyInstaller.depend.bindepend' has no attribute 'selectImports'

Code:

main.py:

from kivy.app import App
from kivy.clock import Clock
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.screenmanager import ScreenManager

from data_routines import DataRtns


class StatLabel(Label):
    def on_text(self, instance, value):
        self.parent.parent.parent.parent.status = value


class Interface(ScreenManager):

    status = "Data Routines"
    err_flg = False

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.clock = Clock.schedule_once(self.process_data, 5)

    def process_data(self, dt):

        if self.status == "Data Routines":
            DataRtns.validate_database(self)
        elif self.status == "Validated Database":
            DataRtns.check_tables(self)
        elif self.status == "Checked Tables":
            DataRtns.check_defaults(self)
        elif self.status == "Checked Defaults":
            self.ids.status_indicator.text = "Finished"

        if self.status != "Finished":

            self.clock.cancel()

            if self.err_flg:
                print(self.ids.status_indicator.text)
                App.get_running_app().stop()
            else:
                self.clock = Clock.schedule_once(self.process_data, 5)


class CandoitApp(App):
    def build(self):
        self.title = "Can Do IT Application"
        self.icon = "cando.png"


if __name__ == "__main__":
    CandoitApp().run()

data_routines.py:

from sqlite3 import connect


class DataRtns:

    db = None
    cursor = None

    @staticmethod
    def validate_database(interface):

        # Create a Connection to Data, create Database if it doesn't exist

        try:
            DataRtns.db = connect("shipping.db")
            DataRtns.cursor = DataRtns.db.cursor()
        except Exception as err:
            interface.err_flg = True
            interface.ids.status_indicator.text = "Connection Failed: " + str(err)

        if interface.err_flg == False:
            interface.ids.status_indicator.text = "Validated Database"

    @staticmethod
    def check_tables(interface):

        # Validate Tables, create if they don't exist

        files = ["addresses", "schedule", "addr_types", "prefixes", "suffixes", "service_types"]

        for file in files:

            if file == "addresses":

                try:

                    DataRtns.cursor.execute("CREATE TABLE IF NOT EXISTS addresses(id INTEGER PRIMARY KEY, "
                                            "street_no INTEGER NOT NULL, street_name TEXT NOT NULL, "
                                            "street_suffix TEXT NOT NULL, street_prefix TEXT, "
                                            "unit_suite TEXT, city TEXT NOT NULL, province TEXT NOT NULL, "
                                            "postal TEXT NOT NULL, landline TEXT, cell TEXT, "
                                            "address_type TEXT NOT NULL, map TEXT, photo TEXT, "
                                            "directions TEXT, location_notes TEXT, "
                                            "cancellations INTEGER DEFAULT 0, failures INTEGER DEFAULT 0, "
                                            "completed INTEGER DEFAULT 0, status TEXT, "
                                            "status_description TEXT, time_stamp TEXT)")

                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem with addresses: " + str(err)
                    break

            elif file == "schedule":

                try:

                    DataRtns.cursor.execute("CREATE TABLE IF NOT EXISTS schedule(rowid INTEGER PRIMARY KEY, "
                                            "addrid INTEGER NOT NULL, address TEXT NOT NULL, "
                                            "city TEXT NOT NULL, type TEXT NOT NULL, "
                                            "notes TEXT, status TEXT, time_stamp TEXT)")

                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem with schedule: " + str(err)
                    break

            elif file == "addr_types":

                try:

                    DataRtns.cursor.execute("CREATE TABLE IF NOT EXISTS addr_types(id INTEGER PRIMARY KEY, "
                                            "type TEXT NOT NULL, multi_unit INTEGER DEFAULT 0)")

                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem with addr_types: " + str(err)
                    break

            elif file == "prefixes":

                try:

                    DataRtns.cursor.execute("CREATE TABLE IF NOT EXISTS prefixes(id INTEGER PRIMARY KEY, "
                                            "street_direction TEXT NOT NULL, abbreviation TEXT NOT NULL)")

                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem with prefixes: " + str(err)
                    break

            elif file == "suffixes":

                try:

                    DataRtns.cursor.execute("CREATE TABLE IF NOT EXISTS suffixes(id INTEGER PRIMARY KEY, "
                                            "street_type TEXT NOT NULL, abbreviation TEXT NOT NULL)")

                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem with suffixes: " + str(err)
                    break

            elif file == "service_types":

                try:

                    DataRtns.cursor.execute("CREATE TABLE IF NOT EXISTS service_types(id INTEGER PRIMARY KEY, "
                                            "type TEXT NOT NULL)")

                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem with service_types: " + str(err)
                    break

        if interface.err_flg == False:
            interface.ids.status_indicator.text = "Checked Tables"

    @staticmethod
    def check_defaults(interface):

        # Validate Maintenance Files, should contain default values used in the application

        result = []
        chk_result = []

        files = ["addr_types", "prefixes", "suffixes", "service_types"]

        for file in files:

            if interface.err_flg:
                break

            if file == "addr_types":

                # Address Type Defaults

                values = [("Apartment Building", 1),
                          ("Assisted Living Building", 1),
                          ("Basement Apartment", 0),
                          ("Business (detached)", 0),
                          ("Condominium", 1),
                          ("Flat", 0),
                          ("House (detached)", 0),
                          ("House (linked)", 0),
                          ("Loft", 0),
                          ("Maisonette", 1),
                          ("Office Building", 1),
                          ("Retirement Home", 1),
                          ("Row House", 1),
                          ("Seniors Residence", 1),
                          ("Store Front", 0),
                          ("Plaza", 1),
                          ("Mall", 1),
                          ("Townhouse", 1),
                          ("Townhouse (no unit)", 0),
                          ("Trailer Park", 0)]

                # Access addr_types

                try:
                    sql = f"SELECT * from {file}"
                    DataRtns.cursor.execute(sql)
                    result = DataRtns.cursor.fetchall()
                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem accessing addr_types: " + str(err)
                    break

                # Check Records

                if len(result) > 0:

                    for value_items in values:

                        try:
                            sql = f"SELECT * from {file} where type = '{value_items[0]}'"
                            DataRtns.cursor.execute(sql)
                            chk_result = DataRtns.cursor.fetchall()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem accessing {file}: " + str(err)
                            break

                        if len(chk_result) == 0:

                            desc = value_items[0]
                            munit = value_items[1]

                            try:
                                sql = f"INSERT INTO {file} (type, multi_unit) VALUES (?, ?)"
                                vals = (f"{desc}", f"{munit}")
                                DataRtns.cursor.execute(sql, vals)
                                DataRtns.db.commit()
                            except Exception as err:
                                DataRtns.db.close()
                                interface.err_flg = True
                                interface.ids.status_indicator.text = f"Problem update {file}: " + str(err)
                                break

                else:

                    # Add Records

                    for value_items in values:

                        desc = value_items[0]
                        munit = value_items[1]

                        try:
                            sql = f"INSERT INTO {file} (type, multi_unit) VALUES (?, ?)"
                            vals = (f"{desc}", f"{munit}")
                            DataRtns.cursor.execute(sql, vals)
                            DataRtns.db.commit()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem updating {file}: " + str(err)
                            break

            elif file == "prefixes":

                # Street Direction Defaults

                values = [("East", "E"),
                          ("North", "N"),
                          ("Northeast", "NE"),
                          ("Northwest", "NW"),
                          ("South", "S"),
                          ("Southeast", "SE"),
                          ("Southwest", "SW"),
                          ("West", "W")]

                # Access prefixes

                try:
                    sql = f"SELECT * from {file}"
                    DataRtns.cursor.execute(sql)
                    result = DataRtns.cursor.fetchall()
                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = "Problem accessing prefixes: " + str(err)
                    break

                # Check Records

                if len(result) > 0:

                    for value_items in values:

                        try:
                            sql = f"SELECT * from {file} where street_direction = '{value_items[0]}'"
                            DataRtns.cursor.execute(sql)
                            chk_result = DataRtns.cursor.fetchall()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem accessing {file}: " + str(err)
                            break

                        if len(chk_result) == 0:

                            direction = value_items[0]
                            short_desc = value_items[1]

                            try:
                                sql = f"INSERT INTO {file} (street_direction, abbreviation) VALUES (?, ?)"
                                vals = (f"{direction}", f"{short_desc}")
                                DataRtns.cursor.execute(sql, vals)
                                DataRtns.db.commit()
                            except Exception as err:
                                DataRtns.db.close()
                                interface.err_flg = True
                                interface.ids.status_indicator.text = f"Problem updating {file}: " + str(err)
                                break

                else:

                    # Add Records

                    for value_items in values:

                        direction = value_items[0]
                        short_desc = value_items[1]

                        try:
                            sql = f"INSERT INTO {file} (street_direction, abbreviation) VALUES (?, ?)"
                            vals = (f"{direction}", f"{short_desc}")
                            DataRtns.cursor.execute(sql, vals)
                            DataRtns.db.commit()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem updating {file}: " + str(err)
                            break

            elif file == "suffixes":

                # Street Type Defaults

                values = [("Abbey", "Abbey"),
                          ("Acres", "Acres"),
                          ("Alley", "Alley"),
                          ("Avenue", "Ave"),
                          ("Bay", "Bay"),
                          ("Beach", "Beach"),
                          ("Boulevard", "Blvd"),
                          ("Bye-pass", "Bypass"),
                          ("Campus", "Campus"),
                          ("Centre", "Ctr"),
                          ("Circle", "Cir"),
                          ("Concession", "Conc"),
                          ("Corners", "Crnrs"),
                          ("Court", "Crt"),
                          ("Cove", "Cove"),
                          ("Crescent", "Cres"),
                          ("Crossing", "Cross"),
                          ("Downs", "Downs"),
                          ("Drive", "Dr"),
                          ("Esplanade", "Espl"),
                          ("Expressway", "Expy"),
                          ("Extension", "Exten"),
                          ("Freeway", "Fwy"),
                          ("Glen", "Glen"),
                          ("Grove", "Grove"),
                          ("Harbour", "Harbr"),
                          ("Heights", "Hts"),
                          ("Highway", "Hwy"),
                          ("Hill", "Hill"),
                          ("Key", "Key"),
                          ("Landing", "Landing"),
                          ("Lane", "Lane"),
                          ("Line", "Line"),
                          ("Mall", "Mall"),
                          ("Manor", "Manor"),
                          ("Meadows", "Meadows"),
                          ("Mews", "Mews"),
                          ("Mountain", "Mtn"),
                          ("Orchard", "Orch"),
                          ("Park", "Pk"),
                          ("Parkway", "Pky"),
                          ("Place", "Pl"),
                          ("Plaza", "Plaza"),
                          ("Promenade", "Prom"),
                          ("Ridge", "Ridge"),
                          ("Road", "Rd"),
                          ("Route", "Rte"),
                          ("Square", "Sq"),
                          ("Street", "St"),
                          ("Terrace", "Terr"),
                          ("Towers", "Towers"),
                          ("Townline", "Tline"),
                          ("Trail", "Trail"),
                          ("View", "View"),
                          ("Village", "Vilge"),
                          ("Way", "Way")]

                # Access Street Types

                try:
                    sql = f"SELECT * from {file}"
                    DataRtns.cursor.execute(sql)
                    result = DataRtns.cursor.fetchall()
                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = f"Problem accessing suffixes: " + str(err)
                    break

                # Check Records

                if len(result) > 0:

                    for value_items in values:

                        try:
                            sql = f"SELECT * from {file} where street_type = '{value_items[0]}'"
                            DataRtns.cursor.execute(sql)
                            chk_result = DataRtns.cursor.fetchall()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem accessing {file}: " + str(err)
                            break

                        if len(chk_result) == 0:

                            strt_type = value_items[0]
                            short_desc = value_items[1]

                            try:
                                sql = f"INSERT INTO {file} (street_type, abbreviation) VALUES (?, ?)"
                                vals = (f"{strt_type}", f"{short_desc}")
                                DataRtns.cursor.execute(sql, vals)
                                DataRtns.db.commit()
                            except Exception as err:
                                DataRtns.db.close()
                                interface.err_flg = True
                                interface.ids.status_indicator = f"Problem updateing {file}: " + str(err)
                                break

                else:

                    # Add Records

                    for value_items in values:

                        strt_type = value_items[0]
                        short_desc = value_items[1]

                        try:
                            sql = f"INSERT INTO {file} (street_type, abbreviation) VALUES (?, ?)"
                            vals = (f"{strt_type}", f"{short_desc}")
                            DataRtns.cursor.execute(sql, vals)
                            DataRtns.db.commit()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem updating {file}: " + str(err)
                            break

            elif file == "service_types":

                # Service Type Defaults

                values = ["Delivery",
                          "Desk Work",
                          "Dog Walking",
                          "Gardening",
                          "Lawn Mow",
                          "Leaf Raking",
                          "Other",
                          "Pet Sitting",
                          "Put Garbage Out",
                          "Snow Shoveling",
                          "Trash Removal"]

                # Access service_types

                try:
                    sql = f"SELECT * from {file}"
                    DataRtns.cursor.execute(sql)
                    result = DataRtns.cursor.fetchall()
                except Exception as err:
                    DataRtns.db.close()
                    interface.err_flg = True
                    interface.ids.status_indicator.text = f"Problem accessing service_types: " + str(err)
                    break

                # Check Records

                if len(result) > 0:

                    for value_items in values:

                        try:
                            sql = f"SELECT * from {file} where type = '{value_items[0]}'"
                            DataRtns.cursor.execute(sql)
                            chk_result = DataRtns.cursor.fetchall()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem accessing {file}: " + str(err)
                            break

                        if len(chk_result) == 0:

                            service = value_items[0]

                            try:
                                sql = f"INSERT INTO {file} (type) VALUES (?)"
                                vals = f"{service}"
                                DataRtns.cursor.execute(sql, vals)
                                DataRtns.db.commit()
                            except Exception as err:
                                DataRtns.db.close()
                                interface.err_flg = True
                                interface.ids.status_indicator.text = f"Problem updating {file}: " + str(err)
                                break

                else:

                    # Add Records

                    for value_items in values:

                        service = value_items[0]

                        try:
                            sql = f"INSERT INTO {file} (type) VALUES (?)"
                            vals = f"{service}"
                            DataRtns.cursor.execute(sql, vals)
                            DataRtns.db.commit()
                        except Exception as err:
                            DataRtns.db.close()
                            interface.err_flg = True
                            interface.ids.status_indicator.text = f"Problem updating {file}: " + str(err)
                            break

        if interface.err_flg == False:

            DataRtns.cursor.close()
            DataRtns.db.close()

            interface.ids.status_indicator.text = "Checked Defaults"

candoit.kv:

Interface:
    Screen:
        name: "Splash_Screen"
        canvas.before:
            Color:
                rgba: .6, .8, 1, 1
            Rectangle:
                pos: self.pos
                size: self.size
        AnchorLayout:
            anchor_x: "center"
            anchor_y: "center"
            BoxLayout:
                orientation: "vertical"
                size_hint: None, None
                width: dp(300)
                height: dp(300)
                Image:
                    source: "cando.png"
                    size_hint: 1, 0.9
                StatLabel:
                    id: status_indicator
                    text: root.status
                    font_size: "32sp"
                    color: [0, 0, 0, 1]
                    size_hint: 1, 0.1

weaved459 avatar Aug 18 '24 12:08 weaved459

I was able to build it w/o the logo though, u need to remember to add the logo to the datas as well. the kivyschool pyinstaller page talks about it on step 4b

3 things:

thing1: u need to add ur other py files to datas:

datas=[("candoit.kv","."),("data_routines.py",".")],

thing2: add the MEIPASS folder as per cheaterman's solution here:

# https://discord.com/channels/423249981340778496/741935529838379028/1148697678004363284
import sys, os
if not sys.stderr:
    os.environ['KIVY_NO_CONSOLELOG'] = '1'

from kivy.resources import resource_add_path

if getattr(sys, 'frozen', False):
    resource_add_path(sys._MEIPASS)

third thing: put the kivy app run code in a try except block with a timer so that when it errors out you can observe the console log. This is because when the app exits, there is no more python code running, and windows automatically closes the window.

image

main.py

# https://github.com/kivy/kivy/issues/8802

from kivy.app import App
from kivy.clock import Clock
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.screenmanager import ScreenManager

from data_routines import DataRtns

# https://discord.com/channels/423249981340778496/741935529838379028/1148697678004363284
import sys, os
if not sys.stderr:
    os.environ['KIVY_NO_CONSOLELOG'] = '1'

from kivy.resources import resource_add_path

if getattr(sys, 'frozen', False):
    resource_add_path(sys._MEIPASS)


class StatLabel(Label):
    def on_text(self, instance, value):
        self.parent.parent.parent.parent.status = value


class Interface(ScreenManager):

    status = "Data Routines"
    err_flg = False

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.clock = Clock.schedule_once(self.process_data, 5)

    def process_data(self, dt):

        if self.status == "Data Routines":
            DataRtns.validate_database(self)
        elif self.status == "Validated Database":
            DataRtns.check_tables(self)
        elif self.status == "Checked Tables":
            DataRtns.check_defaults(self)
        elif self.status == "Checked Defaults":
            self.ids.status_indicator.text = "Finished"

        if self.status != "Finished":

            self.clock.cancel()

            if self.err_flg:
                print(self.ids.status_indicator.text)
                App.get_running_app().stop()
            else:
                self.clock = Clock.schedule_once(self.process_data, 5)


class CandoitApp(App):
    def build(self):
        self.title = "Can Do IT Application"
        # self.icon = "cando.png"


if __name__ == "__main__":
    try:
        CandoitApp().run()
    except Exception as e:
        import traceback
        print("full exception", "".join(traceback.format_exception(*sys.exc_info())))
        import time
        time.sleep(10)

candoit.spec

# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
    ['main6.py'],
    pathex=[],
    binaries=[],
    datas=[("candoit.kv","."),("data_routines.py",".")],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='candoit',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

to use this specfile, run python -m PyInstaller candoit.spec --clean

AccelQuasarDragon avatar Aug 18 '24 20:08 AccelQuasarDragon

Hi AccelQuasarDragon

Modified both the main.spec, main.py and ran the pyinstaller twice, once as I would do normally from within my development env and as you'd shown above but I'm sorry to report I got the same error.... still complaning about select imports.

Do I need to add Sqlite to datas and if so what would be that entry ?

weaved459 avatar Aug 19 '24 12:08 weaved459

Sorry about the image.....

cando

weaved459 avatar Aug 19 '24 12:08 weaved459

This worked for me ...

I've been asking all over the place for some help and the one (helpful reply) from Rok Mandeljc of PyInstallers Github mentioned a previous posting had a similar issue. kivy#8653. This did allow the executable to get created but it still failed when I ran it. With your changes and those below I'm now able to run the executable.

I needed to modify the init.py under kivy. (site-packages/kivy/tools/packaging/pyinstaller_hooks)

#from PyInstaller.depend import bidepend

try:
  from PyInstaller.depend.bindepend import get_imports
except ImportError:
  from PyInstaller.depend.bindepend import selectImports(plugin_filepath)

#plugin_deps = bindepend.selectImports(plugin_filepath)

plugin_deps = get_imports(plugin_filepath)

Appreciate all your help provided. Would be interested to know if the above can be applied to future releases of kivy or is this a patch only for the meantime.

Don

weaved459 avatar Aug 19 '24 13:08 weaved459

One step forward 2 steps back as they say ...

Ran the above against my complete application which includes KivyMD as well and it's failing with a different error.

pyinstaller main.spec

112 INFO: PyInstaller: 6.10.0, contrib hooks: 2024.8 112 INFO: Python: 3.12.5 114 INFO: Platform: Linux-6.8.0-40-generic-x86_64-with-glibc2.35 114 INFO: Python environment: /home/weave/Python_Work/CanDoIt/venv 116 DEPRECATION: Foreign Python environment's site-packages paths added to --paths/pathex: ['./venv/lib64/python3.12/site-packages'] This is ALWAYS the wrong thing to do. If your environment's site-packages is not in PyInstaller's module search path then you are running PyInstaller from a different environment to the one your packages are in. Run print(sys.prefix) without PyInstaller to get the environment you should be using then install and run PyInstaller from that environment instead of this one. This warning will become an error in PyInstaller 7.0. 116 INFO: Module search paths (PYTHONPATH): ['/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages', '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/setuptools/_vendor', '/home/weave/Python_Work/CanDoIt', '/home/weave/Python_Work/CanDoIt/venv/lib64/python3.12/site-packages'] 22 INFO: Kivy: v2.3.0 23 INFO: Logger: Record log in /home/weave/.kivy/logs/kivy_24-08-20_5.txt [INFO ] [Logger ] Record log in /home/weave/.kivy/logs/kivy_24-08-20_5.txt [INFO ] [Kivy ] v2.3.0 23 INFO: Kivy: Installed at "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/init.py" [INFO ] [Kivy ] Installed at "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/init.py" 23 INFO: Python: v3.12.5 (main, Aug 17 2024, 16:46:05) [GCC 11.4.0] [INFO ] [Python ] v3.12.5 (main, Aug 17 2024, 16:46:05) [GCC 11.4.0] 23 INFO: Python: Interpreter at "/home/weave/Python_Work/CanDoIt/venv/bin/python3.12" [INFO ] [Python ] Interpreter at "/home/weave/Python_Work/CanDoIt/venv/bin/python3.12" 23 INFO: Logger: Purge log fired. Processing... [INFO ] [Logger ] Purge log fired. Processing... 25 INFO: Logger: Purge finished! [INFO ] [Logger ] Purge finished! 26 INFO: KivyMD: 2.0.1.dev0, git-Unknown, 2024-08-20 (installed at "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivymd/init.py") [INFO ] [KivyMD ] 2.0.1.dev0, git-Unknown, 2024-08-20 (installed at "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivymd/init.py") 27 INFO: Factory: 195 symbols loaded [INFO ] [Factory ] 195 symbols loaded 99 INFO: Image: Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored) [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored) 107 INFO: Text: Provider: sdl2 [INFO ] [Text ] Provider: sdl2 250 INFO: Window: Provider: sdl2 [INFO ] [Window ] Provider: sdl2 601 INFO: GL: Using the "OpenGL" graphics system [INFO ] [GL ] Using the "OpenGL" graphics system 602 INFO: GL: Backend used [INFO ] [GL ] Backend used 602 INFO: GL: OpenGL version <b'3.0 Mesa 23.2.1-1ubuntu3.1~22.04.2'> [INFO ] [GL ] OpenGL version <b'3.0 Mesa 23.2.1-1ubuntu3.1~22.04.2'> 603 INFO: GL: OpenGL vendor <b'Mesa'> [INFO ] [GL ] OpenGL vendor <b'Mesa'> 603 INFO: GL: OpenGL renderer <b'AMD RV730 (DRM 2.50.0 / 6.8.0-40-generic, LLVM 15.0.7)'> [INFO ] [GL ] OpenGL renderer <b'AMD RV730 (DRM 2.50.0 / 6.8.0-40-generic, LLVM 15.0.7)'> 603 INFO: GL: OpenGL parsed version: 3, 0 [INFO ] [GL ] OpenGL parsed version: 3, 0 603 INFO: GL: Shading version <b'1.30'> [INFO ] [GL ] Shading version <b'1.30'> 604 INFO: GL: Texture max size <8192> [INFO ] [GL ] Texture max size <8192> 604 INFO: GL: Texture max units <16> [INFO ] [GL ] Texture max units <16> 631 INFO: Window: auto add sdl2 input provider [INFO ] [Window ] auto add sdl2 input provider 632 INFO: Window: virtual keyboard not allowed, single mode, not docked [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked 634 DEBUG: discover_hook_directories: Hook directories: ['/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivymd/tools/packaging/pyinstaller', '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/_pyinstaller_hooks_contrib/stdhooks', '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/_pyinstaller_hooks_contrib'] [DEBUG ] [discover_hook_directories] Hook directories: ['/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivymd/tools/packaging/pyinstaller', '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/_pyinstaller_hooks_contrib/stdhooks', '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/_pyinstaller_hooks_contrib'] 924 INFO: Appending 'datas' from .spec 925 INFO: checking Analysis 925 INFO: Building Analysis because Analysis-00.toc is non existent 925 INFO: Running Analysis Analysis-00.toc 925 INFO: Target bytecode optimization level: 0 925 INFO: Initializing module dependency graph... 926 INFO: Caching module graph hooks... 946 INFO: Analyzing base_library.zip ... 1661 INFO: Processing standard module hook 'hook-encodings.py' from '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks' 4242 INFO: Processing standard module hook 'hook-pickle.py' from '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks' 5604 INFO: Processing standard module hook 'hook-heapq.py' from '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks' 6165 INFO: Caching module dependency graph... 6291 INFO: Looking for Python shared library... 6336 INFO: Using Python shared library: /lib/x86_64-linux-gnu/libpython3.12.so 6336 INFO: Analyzing /home/weave/Python_Work/CanDoIt/main.py 6560 INFO: Processing standard module hook 'hook-kivy.py' from '/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks' 6567 INFO: Kivy: v2.3.0 6567 INFO: Logger: Record log in /home/weave/.kivy/logs/kivy_24-08-20_6.txt [INFO ] [Logger ] Record log in /home/weave/.kivy/logs/kivy_24-08-20_6.txt [INFO ] [Kivy ] v2.3.0 6567 INFO: Kivy: Installed at "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/init.py" [INFO ] [Kivy ] Installed at "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/init.py" 6568 INFO: Python: v3.12.5 (main, Aug 17 2024, 16:46:05) [GCC 11.4.0] [INFO ] [Python ] v3.12.5 (main, Aug 17 2024, 16:46:05) [GCC 11.4.0] 6568 INFO: Python: Interpreter at "/home/weave/Python_Work/CanDoIt/venv/bin/python3.12" [INFO ] [Python ] Interpreter at "/home/weave/Python_Work/CanDoIt/venv/bin/python3.12" 6568 INFO: Logger: Purge log fired. Processing... [INFO ] [Logger ] Purge log fired. Processing... 6570 INFO: Logger: Purge finished! [INFO ] [Logger ] Purge finished! 6572 INFO: Factory: 195 symbols loaded [INFO ] [Factory ] 195 symbols loaded 6572 DEBUG: Hook failed with: Traceback (most recent call last): File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 383, in _load_hook_module self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/compat.py", line 610, in importlib_load_source mod_loader.exec_module(mod) File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py", line 16, in from kivy.tools.packaging.pyinstaller_hooks import (add_dep_paths, get_deps_all, get_factory_modules, kivy_modules) File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 82, in from PyInstaller.depend import get_imports ImportError: cannot import name 'get_imports' from 'PyInstaller.depend' (/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/init.py) [DEBUG ] [Hook failed with] Traceback (most recent call last): File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 383, in _load_hook_module self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/compat.py", line 610, in importlib_load_source mod_loader.exec_module(mod) File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py", line 16, in from kivy.tools.packaging.pyinstaller_hooks import (add_dep_paths, get_deps_all, get_factory_modules, kivy_modules) File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 82, in from PyInstaller.depend import get_imports ImportError: cannot import name 'get_imports' from 'PyInstaller.depend' (/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/init.py) 6575 WARNING: stderr: Traceback (most recent call last): Traceback (most recent call last): 6575 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 383, in _load_hook_module File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 383, in _load_hook_module 6576 WARNING: stderr: self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename) self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename) 6576 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6576 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/compat.py", line 610, in importlib_load_source File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/compat.py", line 610, in importlib_load_source 6576 WARNING: stderr: mod_loader.exec_module(mod) mod_loader.exec_module(mod) 6576 WARNING: stderr: File "", line 995, in exec_module File "", line 995, in exec_module 6576 WARNING: stderr: File "", line 488, in _call_with_frames_removed File "", line 488, in _call_with_frames_removed 6576 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py", line 16, in File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py", line 16, in 6577 WARNING: stderr: from kivy.tools.packaging.pyinstaller_hooks import (add_dep_paths, get_deps_all, get_factory_modules, kivy_modules) from kivy.tools.packaging.pyinstaller_hooks import (add_dep_paths, get_deps_all, get_factory_modules, kivy_modules) 6577 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 82, in File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/kivy/tools/packaging/pyinstaller_hooks/init.py", line 82, in 6577 WARNING: stderr: from PyInstaller.depend import get_imports from PyInstaller.depend import get_imports 6577 WARNING: stderr: ImportError: cannot import name 'get_imports' from 'PyInstaller.depend' (/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/init.py) ImportError: cannot import name 'get_imports' from 'PyInstaller.depend' (/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/init.py) 6577 WARNING: stderr:

6577 WARNING: stderr: During handling of the above exception, another exception occurred: During handling of the above exception, another exception occurred: 6577 WARNING: stderr:

6577 WARNING: stderr: Traceback (most recent call last): Traceback (most recent call last): 6577 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/bin/pyinstaller", line 8, in File "/home/weave/Python_Work/CanDoIt/venv/bin/pyinstaller", line 8, in 6577 WARNING: stderr: sys.exit(_console_script_run()) sys.exit(_console_script_run()) 6578 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ 6578 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 231, in _console_script_run File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 231, in _console_script_run 6578 WARNING: stderr: run() run() 6578 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 215, in run File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 215, in run 6578 WARNING: stderr: run_build(pyi_config, spec_file, **vars(args)) run_build(pyi_config, spec_file, **vars(args)) 6578 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 70, in run_build File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/main.py", line 70, in run_build 6578 WARNING: stderr: PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) 6579 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1227, in main File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1227, in main 6579 WARNING: stderr: build(specfile, distpath, workpath, clean_build) build(specfile, distpath, workpath, clean_build) 6579 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1167, in build File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1167, in build 6580 WARNING: stderr: exec(code, spec_namespace) exec(code, spec_namespace) 6580 WARNING: stderr: File "main.spec", line 4, in File "main.spec", line 4, in 6580 WARNING: stderr: a = Analysis( a = Analysis( 6580 WARNING: stderr: ^^^^^^^^^ ^^^^^^^^^ 6580 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 558, in init File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 558, in init 6580 WARNING: stderr: self.postinit() self.postinit() 6580 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/datastruct.py", line 184, in postinit File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/datastruct.py", line 184, in postinit 6581 WARNING: stderr: self.assemble() self.assemble() 6581 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 698, in assemble File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 698, in assemble 6581 WARNING: stderr: program_scripts.append(self.graph.add_script(script)) program_scripts.append(self.graph.add_script(script)) 6581 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6581 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 268, in add_script File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 268, in add_script 6582 WARNING: stderr: self._top_script_node = super().add_script(pathname) self._top_script_node = super().add_script(pathname) 6582 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6582 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1177, in add_script File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1177, in add_script 6582 WARNING: stderr: self._process_imports(n) self._process_imports(n) 6582 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports 6583 WARNING: stderr: target_modules = self._safe_import_hook(*import_info, **kwargs) target_modules = self._safe_import_hook(*import_info, **kwargs) 6583 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6583 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 437, in _safe_import_hook File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 437, in _safe_import_hook 6583 WARNING: stderr: ret_modules = super()._safe_import_hook( ret_modules = super()._safe_import_hook( 6583 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6583 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2065, in _safe_import_hook File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2065, in _safe_import_hook 6584 WARNING: stderr: target_modules = self.import_hook( target_modules = self.import_hook( 6584 WARNING: stderr: ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ 6584 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1249, in import_hook File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1249, in import_hook 6585 WARNING: stderr: target_package, target_module_partname = self._find_head_package( target_package, target_module_partname = self._find_head_package( 6585 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ 6585 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1428, in _find_head_package File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1428, in _find_head_package 6585 WARNING: stderr: target_package = self._safe_import_module( target_package = self._safe_import_module( 6585 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ 6585 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 502, in _safe_import_module File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 502, in _safe_import_module 6586 WARNING: stderr: return super()._safe_import_module(module_basename, module_name, parent_package) return super()._safe_import_module(module_basename, module_name, parent_package) 6586 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6586 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1809, in _safe_import_module File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1809, in _safe_import_module 6586 WARNING: stderr: self._process_imports(n) self._process_imports(n) 6586 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2608, in _process_imports 6587 WARNING: stderr: target_modules = self._safe_import_hook(*import_info, **kwargs) target_modules = self._safe_import_hook(*import_info, **kwargs) 6587 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6587 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 368, in _safe_import_hook File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 368, in _safe_import_hook 6588 WARNING: stderr: excluded_imports = self._find_all_excluded_imports(source_module.identifier) excluded_imports = self._find_all_excluded_imports(source_module.identifier) 6588 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6588 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 356, in _find_all_excluded_imports File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/analysis.py", line 356, in _find_all_excluded_imports 6588 WARNING: stderr: excluded_imports.update(module_hook.excludedimports) excluded_imports.update(module_hook.excludedimports) 6588 WARNING: stderr: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6588 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 316, in getattr File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 316, in getattr 6588 WARNING: stderr: self._load_hook_module() self._load_hook_module() 6589 WARNING: stderr: File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 386, in _load_hook_module File "/home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/depend/imphook.py", line 386, in _load_hook_module 6589 WARNING: stderr: raise ImportErrorWhenRunningHook(self.hook_module_name, self.hook_filename) raise ImportErrorWhenRunningHook(self.hook_module_name, self.hook_filename) 6589 WARNING: stderr: PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_kivy required by hook for module /home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py. Please check whether module __PyInstaller_hooks_0_kivy actually exists and whether the hook is compatible with your version of /home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller. PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_kivy required by hook for module /home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py. Please check whether module __PyInstaller_hooks_0_kivy actually exists and whether the hook is compatible with your version of /home/weave/Python_Work/CanDoIt/venv/lib/python3.12/site-packages/PyInstaller/hooks/hook-kivy.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.

Missing module __Pyinstaller_hooks_0_kivy, checked and there's nothing under my virtual environment directory.

Any idea what's going wrong now ?

weaved459 avatar Aug 20 '24 09:08 weaved459

Ok, that problem has been fixed in the latest version of kivy-reloader. Can you update kivy-reloader and try again?

AccelQuasarDragon avatar Aug 30 '24 18:08 AccelQuasarDragon

I had the same problem, but was able to fix it by modifying the _find_gst_binaries() method in the mentioned init.py in site-packages/kivy/tools/packaging/pyinstaller_hooks. I modified:

lib_filepaths = set()
for plugin_filepath in plugin_filepaths:
    plugin_deps = bindepend.selectImports(plugin_filepath)
    lib_filepaths.update([path for _, path in plugin_deps])

to:

lib_filepaths = set()
for plugin_filepath in plugin_filepaths:
    plugin_deps = []
    if hasattr(bindepend, 'get_imports'):
        plugin_deps = bindepend.get_imports(plugin_filepath)
    else:
        plugin_deps = bindepend.selectImports(plugin_filepath)
    lib_filepaths.update([path for _, path in plugin_deps])

This works for me!!!

DaytonaJohn avatar Dec 06 '24 23:12 DaytonaJohn

Wow, can confirm DaytonaJohn's edit was the fix, worked for me on Ubuntu 24.04 on Virtualbox.

AccelQuasarDragon avatar Dec 09 '24 06:12 AccelQuasarDragon