Edoardo Sorgentone
Edoardo Sorgentone

Reputation: 150

How can I fix this error in pyinstaller?I'm trying to build a kivy app

I'm trying to build an .exe file of a python(v.3.8) script(that includes framework). I run the command pyinstaller cerca.py,but when I run the final .exe I get this error:

[INFO   ] [Logger      ] Record log in C:\Users\sorge\.kivy\logs\kivy_20-07-08_26.txt
[INFO   ] [Kivy        ] v2.0.0rc3, git-20c14b2, 20200615
[INFO   ] [Kivy        ] Installed at "C:\Users\sorge\Desktop\kivy prove\dist\cerca\kivy\__init__.pyc"
[INFO   ] [Python      ] v3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]
[INFO   ] [Python      ] Interpreter at "C:\Users\sorge\Desktop\kivy prove\dist\cerca\cerca.exe"
[INFO   ] [Factory     ] 185 symbols loaded
 Traceback (most recent call last):
   File "cerca.py", line 4, in <module>
   File "c:\users\sorge\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
     exec(bytecode, module.__dict__)
   File "kivy\uix\label.py", line 285, in <module>
   File "c:\users\sorge\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
     exec(bytecode, module.__dict__)
   File "kivy\uix\widget.py", line 244, in <module>
   File "c:\users\sorge\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
     exec(bytecode, module.__dict__)
   File "kivy\graphics\__init__.py", line 89, in <module>
     manage the module state. Use the `ctx` variable as a dictionary. This
   File "kivy\graphics\vertex.pxd", line 15, in init kivy.graphics.instructions
 ModuleNotFoundError: No module named 'kivy.graphics.vertex'
[3572] Failed to execute script cerca

I also tried to build a single .exe (adding --noconsole and --onefile), but I get this error:

"Failed to execute script cerca"

Anyone know how can I fix this problem?

Upvotes: 2

Views: 342

Answers (1)

Varzaru Tiberius
Varzaru Tiberius

Reputation: 91

You can use pyinstaller cerca.py after that you need to edit the spec file to ensure the pyinstaller takes all the data needed , and change in spec at console=True to see the errors in case it apears and after edit in comand line type pyinstaller cerca.spec -y

here is an example of spec.file change path , name , and kv file name and it should work for you

from kivy_deps import sdl2, glew


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

block_cipher = None


a = Analysis(['CalculatorGreutate.py'],
             pathex=['C:\\Users\\varza\\PycharmProjects\\pythonProject5\\calculatorgreutate'],
             binaries=[],
             datas=[],
             hiddenimports=['win32file','win32timezone'],
             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 +=[('Code\calc.kv', 'C:\\Users\\varza\\PycharmProjects\\pythonProject5\\calculatorgreutate\calc.kv', 'DATA'),]


exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='CalculatorGreutate',
          icon='icon.ico',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=False )
coll = COLLECT(exe,
Tree('C:\\Users\\varza\\PycharmProjects\\pythonProject5\\calculatorgreutate\\'),
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               upx=True,
               upx_exclude=[],
               name='CalculatorGreutate')

Upvotes: 1

Related Questions