'Pyinstaller doesnt create running exe for Kivy app

I wrote a programm (with kivy) to help with some logical functions and wanted to build an exe using pyinstaller. The Code runs fine while using .py files. The Problems I encounter are Modules that aren't loaded:

[CRITICAL] [Camera      ] Unable to find any valuable Camera provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
    picamera - ModuleNotFoundError: No module named 'picamera'
      File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\__init__.py", line 62, in core_select_lib
        fromlist=[modulename], level=0)
      File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\camera\camera_picamera.py", line 18, in <module>
        from picamera import PiCamera

    gi - ModuleNotFoundError: No module named 'gi'
      File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\__init__.py", line 62, in core_select_lib
        fromlist=[modulename], level=0)
      File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\camera\camera_gi.py", line 10, in <module>
        from gi.repository import Gst

    opencv - ModuleNotFoundError: No module named 'cv2'
      File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\__init__.py", line 62, in core_select_lib
        fromlist=[modulename], level=0)
      File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\camera\camera_opencv.py", line 48, in <module>
        import cv2
[CRITICAL] [Spelling    ] Unable to find any valuable Spelling provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
enchant - ModuleNotFoundError: No module named 'enchant'
  File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\__init__.py", line 62, in core_select_lib
    fromlist=[modulename], level=0)
  File "c:\users\aayhan\appdata\local\programs\python\python37\lib\site-packages\kivy\core\spelling\spelling_enchant.py", line 12, in <module>
    import enchant

below is the spec file I used, where I used the fix suggesetet from Python to Exe

# -*- mode: python ; coding: utf-8 -*-
from kivy_deps import sdl2, glew

block_cipher = None

a = Analysis(['C:\\Users\\Aayhan\\Desktop\\LogicFunc\\Development\\Logic_Function_UIS.py', 'C:\\Users\\Aayhan\\Desktop\\LogicFunc\\Development\\Generate_Output.py', 'C:\\Users\\Aayhan\\Desktop\\LogicFunc\\Development\\Lambda_Function.py', 'C:\\Users\\Aayhan\\Desktop\\LogicFunc\\Development\\Generate_Output.py'],
             pathex=[],
             binaries=[],
             datas=[('C:\\Users\\Aayhan\\Desktop\\LogicFunc\\Development\\UIS.kv', '.')],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz,
          a.scripts, 
          [],
          exclude_binaries=True,
          name='KorrekturTool',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None)

coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               upx_exclude=[],
               name='KorrekturTool')

My Programm gets an Input which is converted into a lambda Function and then used to generate some information about the function. Does anyone know how to get this modules/only the modules I need?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source