简体   繁体   中英

Pyinstaller .exe [CRITICAL] [Window] error sdl2 - RuntimeError: b'Could not initialize OpenGL / GLES library'

C:\Users\thoma\PycharmProjects\FacesGUI\myexe\dist\main>main.exe
[INFO   ] [Logger      ] Record log in C:\Users\thoma\.kivy\logs\kivy_20-07-30_0.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\thoma\PycharmProjects\FacesGUI\myexe\dist\main\kivy\__init__.pyc"
[INFO   ] [Python      ] v3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\thoma\PycharmProjects\FacesGUI\myexe\dist\main\main.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [Window      ] Activate GLES2/ANGLE context
[CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from
the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - RuntimeError: b'Could not initialize OpenGL / GLES library'
  File "lib\site-packages\kivy\core\__init__.py", line 71, in core_select_lib
  File "lib\site-packages\kivy\core\window\window_sdl2.py", line 152, in __init__
  File "lib\site-packages\kivy\core\window\__init__.py", line 981, in __init__
  File "lib\site-packages\kivy\core\window\window_sdl2.py", line 290, in create_window
  File "kivy\core\window\_window_sdl2.pyx", line 224, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
  File "kivy\core\window\_window_sdl2.pyx", line 74, in kivy.core.window._window_sdl2._WindowSDL2Storage.die

 Traceback (most recent call last):
   File "main.py", line 538, in <module>
   File "lib\site-packages\kivy\lang\builder.py", line 288, in load_file
 FileNotFoundError: [Errno 2] No such file or directory: 'main.kv'
[10100] Failed to execute script main

I am very close (hopefully) to executing the.exe I have built using pyinstaller. I believe the issue is related to the sdl2 or associated.dll(s). I need to point to the sdl2.dll in the.spec file according to this guide

"The previous examples used eg *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins + gstreamer.dep_bins)], to make PyInstaller add all the dlls used by these dependencies. If kivy was not installed using the wheels method these commands will not work and eg kivy_deps.sdl2 will fail to import. Instead, one must find the location of these dlls and manually pass them to the Tree class in a similar fashion as the example."

My.spec

# -*- mode: python -*-

block_cipher = None

face_models = [
('.\\face_recognition_models\\models\\dlib_face_recognition_resnet_model_v1.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\mmod_human_face_detector.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\shape_predictor_5_face_landmarks.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\shape_predictor_68_face_landmarks.dat', './face_recognition_models/models'),
]

a = Analysis(['<main.py>'],
             pathex=['path to working directory'],
             binaries=face_models,
             datas=[],
             hiddenimports=['scipy._lib.messagestream', 'scipy', 'scipy.signal', 'scipy.signal.bsplines', 'scipy.special', 'scipy.special._ufuncs_cxx',
                            'scipy.linalg.cython_blas',
                            'scipy.linalg.cython_lapack',
                            'scipy.integrate',
                            'scipy.integrate.quadrature',
                            'scipy.integrate.odepack',
                            'scipy.integrate._odepack',
                            'scipy.integrate.quadpack',
                            'scipy.integrate._quadpack',
                            'scipy.integrate._ode',
                            'scipy.integrate.vode',
                            'scipy.integrate._dop', 'scipy._lib', 'scipy._build_utils','scipy.__config__',
                            'scipy.integrate.lsoda', 'scipy.cluster', 'scipy.constants','scipy.fftpack','scipy.interpolate','scipy.io','scipy.linalg','scipy.misc','scipy.ndimage','scipy.odr','scipy.optimize','scipy.setup','scipy.sparse','scipy.spatial','scipy.special','scipy.stats','scipy.version'],

             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

a.datas += Tree('./scipy-extra-dll', prefix=None)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='Faces',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )

This spec file was copied from Here and tbh I am uncertain about the majority of its contents. Just trying to get the.exe up and running so I can demo the application.

I added the follwong to the.spec file:

from kivy_deps import glew, sdl2
Tree(<'path to main.py'>),
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],

and this resolved the sdl2 issue for me. I am also using an early gen intel HD graphics card that experiences some issues re: OpenGL and recognising version 2.0+ Some solutions to the sdl2 issue on stackoverflow discuss changing the environment variables for the KIVY BACKEND to glew instead of angle_sdl2 - I have also made this change.

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