1

When i run packeged app according to Kivy site it says

Traceback (most recent call last):
   File "main.py", line 12, in <module>
     from kivy.app import App
   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
   File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
   File "kivy\__init__.py", line 317, in <module>
 AttributeError: 'NoneType' object has no attribute 'load_module'
[21476] Failed to execute script 'main' due to unhandled exception!

line 12 of main.py is

from kivy.app import App

and App is used like this

class MyMainApp(App):
    def build(self):
        self.title = "MyTitle"
        self.default_font = "Lato-Regular"
        return kv

my main.spec

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

block_cipher = None

added_files = [
         ( 'my.kv', '.' ),
         ]

a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas=[],
    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='main',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
coll = COLLECT(exe, Tree('.'),
    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='main',
)

I tried re-generating .spec file with one-file and one-directory and applying changes suggested by kivy official tutorial. Tried to include "kivy.app" in hiddenimports in .spec Tried fallback PyInstaller to older version Nothing changed anything

When i run main.py it works fine, only packaged version have problem

  • 1
    related question, sadly the answer is a bit vague: https://stackoverflow.com/questions/69064929/nonetype-object-has-no-attribute-load-module – Caridorc Jan 31 '23 at 23:12

0 Answers0