简体   繁体   中英

Using PyInstaller to make Kivy App excuteable

After creating a spec (with pyinstaller) file and adding the needed code lines (as kivy documentation describes) i get this txt file "warnHR_specialist" with tons of "missing module named........." lines.

Furthermore GUI it self is working but when im trying to use a button linked to a function i got a Fatal Error saying "Failed to execute script".

This button catches a txt file path, open it & manipulte data using pandas module..is it possible that i should add os module? im really comfused...

Here is the modules im using in my app:

from kivy.app import App
from kivy.uix.button import Button
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
import re
import pandas as pd

I used this command to create the spec file :

 pyinstaller --onedir --name=HR_specialist --windowed "my_file_path_here\HR_specialist.py"

Here is the spec file i got + the kivy changes i made inside it as they describe:

# -*- mode: python -*-
from kivy.deps import sdl2, glew
from os import path
block_cipher = None


a = Analysis(['C:\\Users\\kedem_000\\PycharmProjects\\Projects\\HR_specialist\\HR_specialist.py'],
             pathex=['C:\\Users\\kedem_000\\PycharmProjects\\Projects\\HRexe'],
             binaries=None,
             datas=None,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

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

exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='HR_specialist',
          debug=False,
          strip=False,
          upx=True,
          console=False )

coll = COLLECT(exe, Tree('C:\Users\kedem_000\PycharmProjects\Projects\HR_specialist'),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               name='HR_specialist')

Im trying to solve this problem for more then two weeks and im losing my mind...

If any more information is needed please comment.

Thank you!

Furthermore GUI it self is working but when im trying to use a button linked to a function i got a Fatal Error saying "Failed to execute script".

If GUI works, it means dependencies were successfully packaged into exe/folder (in your case folder). Judgind from this quote even Button event works, so Kivy should be packaged correctly.

However, the errors are about some missing modules (please include log!), therefore it means those modules weren't packaged, or Python can't import it. If they weren't packaged, you'll probably need to include them in hidden_imports if pyinstaller forgot to fetch them to folder too.

If they were packaged (open folder, check), they probably can't be imported. This would seem like you manipulated a path from which imports are fetched in Pycharm and you'll need to edit it .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM