Python “如何修复”;导入错误:无法加载EGL库';,22,找不到指定的模块;

Python “如何修复”;导入错误:无法加载EGL库';,22,找不到指定的模块;,python,exception,opengl,pyopengl,Python,Exception,Opengl,Pyopengl,我想使用python中的pyrender模块从三维模型生成渲染图像。因为这个原因,我用了这个 当我运行此代码生成图像时。我得到了这个错误: -------------------------------------------------------------------------- OSError Traceback (most recent call last) C:\Anaconda3\lib\site-package

我想使用python中的
pyrender
模块从三维模型生成渲染图像。因为这个原因,我用了这个

当我运行此代码生成图像时。我得到了这个错误:

--------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\OpenGL\platform\egl.py in EGL(self)
     69                 'EGL',
---> 70                 mode=ctypes.RTLD_GLOBAL
     71             )

C:\Anaconda3\lib\site-packages\OpenGL\platform\ctypesloader.py in loadLibrary(dllType, name, mode)
     44     try:
---> 45         return dllType( name, mode )
     46     except Exception as err:

C:\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    347         if handle is None:
--> 348             self._handle = _dlopen(self._name, mode)
    349         else:

OSError: [WinError 126] Le module spécifié est introuvable

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-e86166a3612b> in <module>()
      4 import numpy as np
      5 import trimesh
----> 6 import pyrender
      7 
      8 # Load the FUZE bottle trimesh and put it in a scene

C:\Anaconda3\lib\site-packages\pyrender\__init__.py in <module>()
      1 from .camera import (Camera, PerspectiveCamera, OrthographicCamera,
      2                      IntrinsicsCamera)
----> 3 from .light import Light, PointLight, DirectionalLight, SpotLight
      4 from .sampler import Sampler
      5 from .texture import Texture

C:\Anaconda3\lib\site-packages\pyrender\light.py in <module>()
      9 
     10 from .utils import format_color_vector
---> 11 from .texture import Texture
     12 from .constants import SHADOW_TEX_SZ
     13 from .camera import OrthographicCamera, PerspectiveCamera

C:\Anaconda3\lib\site-packages\pyrender\texture.py in <module>()
      6 import numpy as np
      7 
----> 8 from OpenGL.GL import *
      9 
     10 from .utils import format_texture_source

C:\Anaconda3\lib\site-packages\OpenGL\GL\__init__.py in <module>()
      1 """OpenGL.GL, the core GL library and extensions to it"""
      2 # early import of our modules to prevent import loops...
----> 3 from OpenGL import error as _error
      4 from OpenGL.GL.VERSION.GL_1_1 import *
      5 from OpenGL.GL.pointers import *

C:\Anaconda3\lib\site-packages\OpenGL\error.py in <module>()
     10 import logging
     11 _log = logging.getLogger( 'OpenGL.error' )
---> 12 from OpenGL import platform, _configflags
     13 from ctypes import ArgumentError
     14 __all__ = (

C:\Anaconda3\lib\site-packages\OpenGL\platform\__init__.py in <module>()
     33     return plugin
     34 
---> 35 _load()
     36 
     37 def types(resultType,*argTypes):

C:\Anaconda3\lib\site-packages\OpenGL\platform\__init__.py in _load()
     30 
     31     # install into the platform module's namespace now
---> 32     plugin.install(globals())
     33     return plugin
     34 

C:\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py in install(self, namespace)
     90         """Install this platform instance into the platform module"""
     91         for name in self.EXPORTED_NAMES:
---> 92             namespace[ name ] = getattr(self,name,None)
     93         namespace['PLATFORM'] = self
     94         return self

C:\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py in __get__(self, obj, cls)
     12         self.fget = function
     13     def __get__( self, obj, cls ):
---> 14         value = self.fget( obj )
     15         setattr( obj, self.fget.__name__, value)
     16         return value

C:\Anaconda3\lib\site-packages\OpenGL\platform\egl.py in GetCurrentContext(self)
     91     @baseplatform.lazy_property
     92     def GetCurrentContext( self ):
---> 93         return self.EGL.eglGetCurrentContext

C:\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py in __get__(self, obj, cls)
     12         self.fget = function
     13     def __get__( self, obj, cls ):
---> 14         value = self.fget( obj )
     15         setattr( obj, self.fget.__name__, value)
     16         return value

C:\Anaconda3\lib\site-packages\OpenGL\platform\egl.py in EGL(self)
     71             )
     72         except OSError as err:
---> 73             raise ImportError("Unable to load EGL library", *err.args)
     74     @baseplatform.lazy_property
     75     def getExtensionProcedure( self ):

ImportError: ('Unable to load EGL library', 22, 'Le module spécifié est introuvable', None, 126, None, 'EGL', None)
--------------------------------------------------------------------------
OSError回溯(最近一次调用上次)
C:\Anaconda3\lib\site packages\OpenGL\platform\egl.py在egl中(self)
69‘EGL’,
--->70模式=ctypes.RTLD_全局
71             )
loadLibrary中的C:\Anaconda3\lib\site packages\OpenGL\platform\ctypesloader.py(dllType、name、mode)
44尝试:
--->45返回dllType(名称、模式)
46除作为错误的例外情况外:
C:\Anaconda3\lib\ctypes\\uuuuu init\uuuu.py in\uuuuu init\uuuu(self、name、mode、handle、use\u errno、use\u last\u error)
347如果句柄为“无”:
-->348 self.\u handle=\u dlopen(self.\u名称,模式)
349其他:
OSError:[WinError 126]模块spécifiéest可插入
在处理上述异常期间,发生了另一个异常:
ImportError回溯(最近一次呼叫最后一次)
在()
4作为np导入numpy
5进口三角帆
---->6进口除虫菊
7.
8#装上引信瓶饰物并将其放在场景中
C:\Anaconda3\lib\site packages\pyender\\uuuuu init\uuuuuuu.py in()
1.摄影机导入(摄影机、透视摄影机、正交摄影机、,
2个内置摄像头)
---->3从光源导入光源、点光源、方向光源、聚光灯
4.取样器进口取样器
5.从纹理导入纹理
C:\Anaconda3\lib\site packages\pyender\light.py in()
9
10从.utils导入格式\u颜色\u向量
--->11.从纹理导入纹理
12 from.常量导入SHADOW_TEX_SZ
13.从摄影机导入正交摄影机、透视摄影机
C:\Anaconda3\lib\site packages\pyender\texture.py in()
6作为np进口numpy
7.
---->8从OpenGL.GL导入*
9
10从.utils导入格式\u纹理\u源
C:\Anaconda3\lib\site packages\OpenGL\GL\\uuuuu init\uuuuuuuuu.py in()
1“OpenGL.GL,核心GL库及其扩展”
2#尽早导入我们的模块以防止导入循环。。。
---->3从OpenGL导入错误为_错误
4从OpenGL.GL.VERSION.GL_1_1导入*
5从OpenGL.GL.pointers导入*
C:\Anaconda3\lib\site packages\OpenGL\error.py in()
10导入日志
11 _log=logging.getLogger('OpenGL.error')
--->12从OpenGL导入平台,\u configflags
13从ctypes导入参数错误
14 uuu所有uuu=(
C:\Anaconda3\lib\site packages\OpenGL\platform\\uuuuu init\uuuuuuuu.py in()
33返回插件
34
--->35_载荷()
36
37个def类型(结果类型,*argTypes):
C:\Anaconda3\lib\site packages\OpenGL\platform\\uuuuu init\uuuuuuuu.py in\u load()
30
31#立即安装到平台模块的命名空间中
--->32 plugin.install(globals())
33返回插件
34
安装中的C:\Anaconda3\lib\site packages\OpenGL\platform\baseplatform.py(self,名称空间)
90“将此平台实例安装到平台模块中”
91对于自导出名称中的名称:
--->92名称空间[name]=getattr(self、name、None)
93命名空间['PLATFORM']=self
94回归自我
C:\Anaconda3\lib\site packages\OpenGL\platform\baseplatform.py in\uuuuuu get\uuuuuuu(self、obj、cls)
12 self.fget=函数
13定义获取(自身、obj、cls):
--->14值=自身fget(obj)
15 setattr(对象、自身、设置名称、值)
16返回值
GetCurrentContext(self)中的C:\Anaconda3\lib\site packages\OpenGL\platform\egl.py
91@baseplatform.lazy_属性
92 def GetCurrentContext(自身):
--->93返回self.EGL.eglGetCurrentContext
C:\Anaconda3\lib\site packages\OpenGL\platform\baseplatform.py in\uuuuuu get\uuuuuuu(self、obj、cls)
12 self.fget=函数
13定义获取(自身、obj、cls):
--->14值=自身fget(obj)
15 setattr(对象、自身、设置名称、值)
16返回值
C:\Anaconda3\lib\site packages\OpenGL\platform\egl.py在egl中(self)
71             )
72除操作错误作为错误外:
--->73提升导入错误(“无法加载EGL库”,*err.args)
74@baseplatform.lazy_属性
75 def getExtensionProcedure(自):
ImportError:(“无法加载EGL库”,22,“Le模块规格est可导入”,无,126,无,“EGL”,无)
我在python中安装了所有必要的模块,比如
pyrender
module,但我不知道问题出在哪里。 这里是pyrender工作的链接。

你可以试试

apt get install libglfw3 dev libgles2 mesa dev

这就解决了我的问题。 希望对您有所帮助。

在我的例子中(Ubuntu 18.04,pyrender==1.43,python==3.7.8)

解决了这个问题。
也许第一行不是必需的。

如果您在windows上,只需注释掉指定PYOPENGL_平台的那一行。

您解决过这个问题吗?怎么做?
--------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\OpenGL\platform\egl.py in EGL(self)
     69                 'EGL',
---> 70                 mode=ctypes.RTLD_GLOBAL
     71             )

C:\Anaconda3\lib\site-packages\OpenGL\platform\ctypesloader.py in loadLibrary(dllType, name, mode)
     44     try:
---> 45         return dllType( name, mode )
     46     except Exception as err:

C:\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    347         if handle is None:
--> 348             self._handle = _dlopen(self._name, mode)
    349         else:

OSError: [WinError 126] Le module spécifié est introuvable

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-e86166a3612b> in <module>()
      4 import numpy as np
      5 import trimesh
----> 6 import pyrender
      7 
      8 # Load the FUZE bottle trimesh and put it in a scene

C:\Anaconda3\lib\site-packages\pyrender\__init__.py in <module>()
      1 from .camera import (Camera, PerspectiveCamera, OrthographicCamera,
      2                      IntrinsicsCamera)
----> 3 from .light import Light, PointLight, DirectionalLight, SpotLight
      4 from .sampler import Sampler
      5 from .texture import Texture

C:\Anaconda3\lib\site-packages\pyrender\light.py in <module>()
      9 
     10 from .utils import format_color_vector
---> 11 from .texture import Texture
     12 from .constants import SHADOW_TEX_SZ
     13 from .camera import OrthographicCamera, PerspectiveCamera

C:\Anaconda3\lib\site-packages\pyrender\texture.py in <module>()
      6 import numpy as np
      7 
----> 8 from OpenGL.GL import *
      9 
     10 from .utils import format_texture_source

C:\Anaconda3\lib\site-packages\OpenGL\GL\__init__.py in <module>()
      1 """OpenGL.GL, the core GL library and extensions to it"""
      2 # early import of our modules to prevent import loops...
----> 3 from OpenGL import error as _error
      4 from OpenGL.GL.VERSION.GL_1_1 import *
      5 from OpenGL.GL.pointers import *

C:\Anaconda3\lib\site-packages\OpenGL\error.py in <module>()
     10 import logging
     11 _log = logging.getLogger( 'OpenGL.error' )
---> 12 from OpenGL import platform, _configflags
     13 from ctypes import ArgumentError
     14 __all__ = (

C:\Anaconda3\lib\site-packages\OpenGL\platform\__init__.py in <module>()
     33     return plugin
     34 
---> 35 _load()
     36 
     37 def types(resultType,*argTypes):

C:\Anaconda3\lib\site-packages\OpenGL\platform\__init__.py in _load()
     30 
     31     # install into the platform module's namespace now
---> 32     plugin.install(globals())
     33     return plugin
     34 

C:\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py in install(self, namespace)
     90         """Install this platform instance into the platform module"""
     91         for name in self.EXPORTED_NAMES:
---> 92             namespace[ name ] = getattr(self,name,None)
     93         namespace['PLATFORM'] = self
     94         return self

C:\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py in __get__(self, obj, cls)
     12         self.fget = function
     13     def __get__( self, obj, cls ):
---> 14         value = self.fget( obj )
     15         setattr( obj, self.fget.__name__, value)
     16         return value

C:\Anaconda3\lib\site-packages\OpenGL\platform\egl.py in GetCurrentContext(self)
     91     @baseplatform.lazy_property
     92     def GetCurrentContext( self ):
---> 93         return self.EGL.eglGetCurrentContext

C:\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py in __get__(self, obj, cls)
     12         self.fget = function
     13     def __get__( self, obj, cls ):
---> 14         value = self.fget( obj )
     15         setattr( obj, self.fget.__name__, value)
     16         return value

C:\Anaconda3\lib\site-packages\OpenGL\platform\egl.py in EGL(self)
     71             )
     72         except OSError as err:
---> 73             raise ImportError("Unable to load EGL library", *err.args)
     74     @baseplatform.lazy_property
     75     def getExtensionProcedure( self ):

ImportError: ('Unable to load EGL library', 22, 'Le module spécifié est introuvable', None, 126, None, 'EGL', None)
sudo apt-get install libosmesa6-dev
sudo apt-get install freeglut3-dev