Search code examples
pythonkivypyinstaller

Pyinstaller Kivy app ValueError: not enough values to unpack (expected 3, got 2)


So basically I've been making an app with Kivy and now I want to compile it to a single executable using pyinstaller. I followed the steps in official kivy guide and the pyinstaller spec files docs (though not as much), and when I tried running my spec file, here's what printed in the terminal:

C:\Users\HP\Desktop\TPM-Kivy>pyinstaller TPManager.spec
9680 INFO: PyInstaller: 4.3
9680 INFO: Python: 3.9.6
9968 INFO: Platform: Windows-10-10.0.19042-SP0
10063 INFO: UPX is not available.
12270 INFO: Extending PYTHONPATH with paths
['C:\\Users\\HP\\Desktop\\TPM-Kivy', 'C:\\Users\\HP\\Desktop\\TPM-Kivy']
64392 INFO: checking Analysis
138561 INFO: checking PYZ
139010 INFO: checking Tree
161817 INFO: checking Tree
162301 INFO: checking Tree
 Traceback (most recent call last):
162502 WARNING: stderr: Traceback (most recent call last):
   File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
162848 WARNING: stderr:   File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
     return _run_code(code, main_globals, None,
163351 WARNING: stderr:     return _run_code(code, main_globals, None,
   File "c:\python39\lib\runpy.py", line 87, in _run_code
163351 WARNING: stderr:   File "c:\python39\lib\runpy.py", line 87, in _run_code
     exec(code, run_globals)
163353 WARNING: stderr:     exec(code, run_globals)
   File "C:\Python39\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
163354 WARNING: stderr:   File "C:\Python39\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
   File "c:\python39\lib\site-packages\PyInstaller\__main__.py", line 114, in run
163355 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\__main__.py", line 114, in run
     run_build(pyi_config, spec_file, **vars(args))
163600 WARNING: stderr:     run_build(pyi_config, spec_file, **vars(args))
   File "c:\python39\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
163721 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
     PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
163723 WARNING: stderr:     PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
   File "c:\python39\lib\site-packages\PyInstaller\building\build_main.py", line 737, in main
163724 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\building\build_main.py", line 737, in main
     build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
163822 WARNING: stderr:     build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
   File "c:\python39\lib\site-packages\PyInstaller\building\build_main.py", line 684, in build
163825 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\building\build_main.py", line 684, in build
     exec(code, spec_namespace)
163827 WARNING: stderr:     exec(code, spec_namespace)
   File "TPManager.spec", line 27, in <module>
163829 WARNING: stderr:   File "TPManager.spec", line 27, in <module>
     exe = EXE(pyz, Tree('C:\\Users\\HP\\Desktop\\TPM-Kivy'),
163830 WARNING: stderr:     exe = EXE(pyz, Tree('C:\\Users\\HP\\Desktop\\TPM-Kivy'),
   File "c:\python39\lib\site-packages\PyInstaller\building\api.py", line 402, in __init__
163831 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\building\api.py", line 402, in __init__
     self.toc.extend(arg)
164157 WARNING: stderr:     self.toc.extend(arg)
   File "c:\python39\lib\site-packages\PyInstaller\building\datastruct.py", line 103, in extend
164158 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\building\datastruct.py", line 103, in extend
     self.append(entry)
164246 WARNING: stderr:     self.append(entry)
   File "c:\python39\lib\site-packages\PyInstaller\building\datastruct.py", line 73, in append
164247 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\building\datastruct.py", line 73, in append
     unique = unique_name(entry)
164248 WARNING: stderr:     unique = unique_name(entry)
   File "c:\python39\lib\site-packages\PyInstaller\building\datastruct.py", line 35, in unique_name
164250 WARNING: stderr:   File "c:\python39\lib\site-packages\PyInstaller\building\datastruct.py", line 35, in unique_name
     name, path, typecode = entry
164252 WARNING: stderr:     name, path, typecode = entry
 ValueError: not enough values to unpack (expected 3, got 2)
164253 WARNING: stderr: ValueError: not enough values to unpack (expected 3, got 2)

I have absolutely no clue on why this happened so here I am. Anyone knows what's the reason behind this error and solution? Any help would be appreciated!

Also here's my spec file:

TPManager.spec

from kivy_deps import sdl2, glew

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


block_cipher = None


a = Analysis(['main.py'],
             pathex=['C:\\Users\\HP\\Desktop\\TPM-Kivy'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             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)

a.datas += [('./main.kv', '.')]
a.datas += [('./Resources', 'Resources')]

exe = EXE(pyz, Tree('C:\\Users\\HP\\Desktop\\TPM-Kivy'),
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
          name='TPManager',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True , icon='GUIIcon.ico')

Solution

  • Well, I managed to solve my problems by myself so for anyone who came here after this then, the problem is with the .spec file (or at least in my case) in this line:

    a.datas += [('./main.kv', '.')]
    a.datas += [('./Resources', 'Resources')]
    

    And the solution here is to actually put your data in the datas variable in the Analysis class and not adding them later, like this:

    from kivy_deps import sdl2, glew
    
    # -*- mode: python ; coding: utf-8 -*-
    
    
    block_cipher = None
    
    
    a = Analysis(['main.py'],
                 pathex=['C:\\Users\\HP\\Desktop\\TPM-Kivy'],
                 binaries=[],
                 #put your data here instead of adding it in later
                 datas=[('./main.kv', '.'), ('./Resources', 'Resources')], 
                 hiddenimports=[],
                 hookspath=[],
                 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, Tree('C:\\Users\\HP\\Desktop\\TPM-Kivy'),
              a.scripts,
              a.binaries,
              a.zipfiles,
              a.datas,
              *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
              name='TPManager',
              debug=False,
              bootloader_ignore_signals=False,
              strip=False,
              upx=True,
              upx_exclude=[],
              runtime_tmpdir=None,
              console=True , icon='GUIIcon.ico')