Pyinstaller .exe [CRITICAL] [Window] error sdl2 - RuntimeError: b'Could not initialize OpenGL / GLES library'
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
我非常接近(希望)执行我使用 pyinstaller 构建的 .exe。我认为该问题与 sdl2 或关联的 .dll(s) 有关。我需要根据this guide
指向.spec文件中的sdl2.dll
"前面的示例使用了例如 *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins + gstreamer.dep_bins)], 让 PyInstaller 添加所有使用的 dll这些依赖项。如果没有使用 wheels 方法安装 kivy,这些命令将不起作用,例如 kivy_deps.sdl2 将无法导入。相反,必须找到这些 dll 的位置并手动将它们传递给树 class 以与示例类似的方式。"
我的.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 )
此规范文件是从 Here 复制而来的,但我不确定其大部分内容。只是想启动 .exe 和 运行 以便我可以演示该应用程序。
我将 follwong 添加到 .spec 文件中:
from kivy_deps import glew, sdl2
Tree(<'path to main.py'>),
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
这为我解决了 sdl2 问题。我也在使用早期的英特尔高清显卡,它遇到了一些问题:OpenGL 和识别 2.0+ 版
Whosebug 上 sdl2 问题的一些解决方案讨论了将 KIVY BACKEND 的环境变量更改为 glew 而不是 angle_sdl2 - 我也进行了此更改。
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
我非常接近(希望)执行我使用 pyinstaller 构建的 .exe。我认为该问题与 sdl2 或关联的 .dll(s) 有关。我需要根据this guide
指向.spec文件中的sdl2.dll"前面的示例使用了例如 *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins + gstreamer.dep_bins)], 让 PyInstaller 添加所有使用的 dll这些依赖项。如果没有使用 wheels 方法安装 kivy,这些命令将不起作用,例如 kivy_deps.sdl2 将无法导入。相反,必须找到这些 dll 的位置并手动将它们传递给树 class 以与示例类似的方式。"
我的.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 )
此规范文件是从 Here 复制而来的,但我不确定其大部分内容。只是想启动 .exe 和 运行 以便我可以演示该应用程序。
我将 follwong 添加到 .spec 文件中:
from kivy_deps import glew, sdl2
Tree(<'path to main.py'>),
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
这为我解决了 sdl2 问题。我也在使用早期的英特尔高清显卡,它遇到了一些问题:OpenGL 和识别 2.0+ 版 Whosebug 上 sdl2 问题的一些解决方案讨论了将 KIVY BACKEND 的环境变量更改为 glew 而不是 angle_sdl2 - 我也进行了此更改。