I'm trying to integrate a filechooser module included in kivy to allow users to go grab the file string of an input file via FileChooserListView, but when building the application through pyinstaller the application doesn't open. Anyone happen to know what the problem is? Here's an example code: works fine in pycharm, but won't open when pyinstaller builds it.
from os.path import exists
from threading import Thread
from sys import exit
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.lang import Builder
from os.path import sep, expanduser, dirname, splitext
from kivy.uix.filechooser import FileChooserListView
KV = '''
<MetaLevel>:
rows: 2
cols: 1
Label:
text: 'test text'
Button:
text: 'test button'
on_press: root.popup()
<file_popup>:
file_chooser: file_chooser
GridLayout:
rows:1
cols:1
FileChooserListView:
id: file_chooser
path: r'C:\\Users'
on_submit: root.printer()
'''
Builder.load_string(KV)
class MetaLevel(GridLayout):
def popup(self):
App.get_running_app().file_popup.open()
class file_popup(Popup):
def printer(self):
print(self.file_chooser.path)
App.get_running_app().file_popup.dismiss()
class Cruncher(App):
def build(self):
self.file_popup = file_popup()
return MetaLevel()
if __name__ == "__main__":
Cruncher().run()
Check to make sure you have the libraries installed:
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
I did get your script to successfully build, after some digging it looks like win32file
and specifically win32timezone
are some hidden imports.
setup:
C:/
..Temp/
....Test/
......test.py <- Your posted code
......TEST.spec
TEST.spec
file:
from kivy_deps import sdl2, glew
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['C:/Temp/Test/test.py'],
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)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='TEST',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False)
coll = COLLECT(exe, Tree('C:\\Temp\\Test\\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='TEST')
Then running pyinstaller C:/Temp/Test/TEST.spec
if you want a --onefile
(I usually do):
TEST.spec
file:
from kivy_deps import sdl2, glew
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['C:/Temp/Test/test.py'],
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)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
[],
name='TEST',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False)