EXE bundled with pyinstaller fails with ImportError: No module named 'kivy.weakmethod'

949 views
Skip to first unread message

Andreas Ecker

unread,
Jan 27, 2017, 12:55:33 PM1/27/17
to Kivy users support
Kivy: 1.9.2-dev0.13012017.67b9bebd - installed from nightly wheels
Python: Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
OS: Windows 7 Pro Service Pack 1 64 bit
Pyinstaller: 3.2.1


The error message after running the EXE file:

[INFO   ] [Logger      ] Record log in C:\Users\aecker.ACUMEN\.kivy\logs\kivy_17-01-27_21.txt
[INFO   ] [Kivy        ] v1.9.2-dev0.13012017.67b9bebd
[INFO   ] [Python      ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]
 
Traceback (most recent call last):
   
File "SihotResImport.py", line 441, in <module>
     
from kivy.app import App
   
File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
     
exec(bytecode, module.__dict__)
   
File "site-packages\kivy\app.py", line 319, in <module>
   
File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
     
exec(bytecode, module.__dict__)
   
File "site-packages\kivy\base.py", line 29, in <module>
   
File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
     
exec(bytecode, module.__dict__)
   
File "site-packages\kivy\clock.py", line 362, in <module>
   
File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 573, in load_module
     
module = loader.load_module(fullname)
   
File "kivy\_clock.pyx", line 9, in init kivy._clock (kivy\_clock.c:13849)
 
ImportError: No module named 'kivy.weakmethod'


Content of my pyinstaller spec file (Following the instructions on the kivy pyinstaller page: https://kivy.org/docs/guide/packaging-windows.html):


# -*- mode: python -*-
from kivy.deps import sdl2, glew


block_cipher
= None


print(sdl2.dep_bins + glew.dep_bins)


a
= Analysis(['SihotResImport.py'],
             pathex
=['C:\\src\\python\\AcuSihotInterfaces\\SihotResImport'],
             binaries
=None,
             datas
=[('SihotResImport.kv', '.')],
             hiddenimports
=[],
             hookspath
=[],  #'C:\\Python34\\Lib\\site-packages\\kivy\\tools\\packaging\\pyinstaller_hooks'],
             
#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,
          a
.binaries,
          a
.zipfiles,
          a
.datas,
         
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
          name
='SihotResImport',
         
#exclude_binaries=True,
          debug
=True,
          strip
=False,
          upx
=True,
          console
=True )


I also tried without specifying the hookspath and with/without exclude_binaries without any difference. Also a direct build without a modified spec file shows the same error.

And as you can see in the error: pyinstaller seems to find and include most of the kivy core modules but kivy.weakmethod seems to be missing.


Andreas Ecker

unread,
Jan 28, 2017, 12:21:14 PM1/28/17
to Kivy users support
The kivy app I want to convert into an onefile-EXE can be found on github: https://github.com/AndiEcker/AcuSihotInterfaces.

For to reproduce simply use the two attached files (or download SihotResImport.py and SihotResImport.kv from this repo) and then follow the steps given in  https://kivy.org/docs/guide/packaging-windows.html

Fighting the whole day with this problem - any pointer would be highly appreciated :)
SihotResImport.spec
SihotResImport.kv
SihotResImport.py

Andreas Ecker

unread,
Feb 4, 2017, 9:36:08 AM2/4/17
to kivy-...@googlegroups.com
After some tweaking I think I found the problem within the pyinstaller kivy hook module (C:\Python34\Lib\site-packages\PyInstaller\hooks\hook-kivy.py). At least by hot-patching the code line

    `if is_module_satisfies('kivy >= 1.9.1'):`

into `if True:` the EXE runs without any crash/error (and the warning "Hook disabled because of Kivy version < 1.9.1" disappears from the console output on app startup).

I am using the nightly kivy wheels from last week and the newest pyinstaller (3.2.1). Unfortunately I am currently very busy with urgent tasks, so would highly appreciate if somebody could fix this upstream within pyinstaller.


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages