由PyInstaller编译的Kivy应用程序不起作用

时间:2019-04-30 20:41:37

标签: python kivy pyinstaller

myapp.py是可行的。编译exe后,发生错误。 Kivy:v1.10.1 Python:v3.6.5

仅myapp.py无需编译即可运行良好。它只包含一个按钮。

myapp.spec:

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


a = Analysis(['myapp.py'],
             pathex=['C:\\Users\\Username\\Desktop\\test'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             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='myapp',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               name='myapp')

控制台:

[CRITICAL] Text: Unable to find any valuable Text provider.
sdl2 - ImportError: DLL load failed: Не найдена указанная процедура.
  File "D:\Python\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "D:\Python\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "D:\Python\lib\site-packages\kivy\core\text\text_sdl2.py", line 12, in <module>
    from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ModuleNotFoundError: No module named 'PIL'
  File "D:\Python\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "D:\Python\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "D:\Python\lib\site-packages\kivy\core\text\text_pil.py", line 7, in <module>
    from PIL import Image, ImageFont, ImageDraw

[CRITICAL] App: Unable to get a Text provider, abort.

有什么问题,我需要做什么? 预先感谢。

1 个答案:

答案 0 :(得分:0)

python -m pip install opencv-contrib-python-headless
python -m pip install pyenchant
python -m pip install cython
python -m pip install Pillow