Building one file executable with PyInstaller

297 views
Skip to first unread message

igorag...@yahoo.com

unread,
Apr 3, 2021, 8:43:16 AM4/3/21
to Kivy users support
Hi,
I have python 3.8 and kivy - python application, which is running without any problem. Now I trying to build "onefile" executable from it following instructions: https://kivy.org/doc/stable/guide/packaging-windows.html.
Everything goes smoothly until the very last step: to run PyInstaller with edited .spec file, I'm getting: "NameError: name 'sdl2' is not defined". 

Before of it I did install sdl2 together with kivy:
python -m pip install kivy[full] kivy_examples
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2==0.3.* kivy.deps.glew 
python -m pip install kivy.deps.gstreamer 
python -m pip install kivy.deps.angle

Does anybody has any idea what I'm doing wrong?
Thank you.

Elliot Garbus

unread,
Apr 3, 2021, 8:54:53 AM4/3/21
to kivy-...@googlegroups.com

I do a single directory build using Pyinstaller.  I have never done a successful one file executable. 

On Windows I then use the Inno Setup compiler to build a Windows Installer: https://jrsoftware.org/isinfo.php

 

Here is an example of my spec file for Windows.  I create a directory under my project directory call my_project_dist and put the spec file in that directory.  All of the directories that Pyinstaller creates are created under that directory.  This has an impact on the paths I use in my spec file.

 

# -*- mode: python -*-


import os
from kivy_deps import sdl2, glew

spec_root = os.path.abspath(SPECPATH)
block_cipher =
None
app_name = 'My App Name'
win_icon = '../Images/app_design_icon.ico'

a = Analysis(['../main.py'],
            
pathex=[spec_root],
            
datas=[('../*.kv', '.'),                    # These will need to be customized for your app
                    (
'../Images/*.png', './Images')],
            
hiddenimports=['win32timezone'],            # this is a dependency for filechooser
            
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=app_name,
         
debug=False,
         
bootloader_ignore_signals=False,
         
strip=False,
         
upx=False,
         
console=False,
         
icon=win_icon)
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p)
for p in (sdl2.dep_bins + glew.dep_bins)],
              
strip=False,
              
upx=False,
              
name=app_name)

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6ae52c33-a250-42ac-af55-5293e16a70a8n%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages