Home > other >  issue with OpenGL library load on mac m1 , using pyopengl
issue with OpenGL library load on mac m1 , using pyopengl

Time:04-22

i have these imports

import pygame
from pygame.locals import *
from OpenGL.GL import * # issue with this one 
from OpenGL.GLU import *

error is :

OSError: ("dlopen(OpenGL, 0x000A): tried: '/Users/aryansingh/miniconda3/lib/OpenGL'

error stack :

Traceback (most recent call last):
File "/Users/aryansingh/miniconda3/lib/python3.9/site- 
packages/OpenGL/platform/darwin.py", line 35, in GL
return ctypesloader.loadLibrary(
File "/Users/aryansingh/miniconda3/lib/python3.9/site- 
packages/OpenGL/platform/ctypesloader.py", line 45, in loadLibrary
return dllType( name, mode )
File "/Users/aryansingh/miniconda3/lib/python3.9/ctypes/__init__.py", line 382, in 
__init__
self._handle = _dlopen(self._name, mode)
OSError: ("dlopen(OpenGL, 0x000A): tried:

tried fix from this answer : Unable to import opengl.gl in python on macos

content of site-packages/OpenGL/platform/ctypesloader.py file where error occurs is like this :

 if isinstance( dllType, ctypes.LibraryLoader ):
     dllType = dllType._dlltype
 fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'#None this path was edited it was none before , LOCALCHANGES
 try:
     fullName = util.find_library( name )
     if fullName is not None:
         name = fullName
     elif os.path.isfile( os.path.join( DLL_DIRECTORY, name   '.dll' )):
         name = os.path.join( DLL_DIRECTORY, name   '.dll' )
 except Exception as err:
     _log.info( '''Failed on util.find_library( %r ): %s''', name, err )
     # Should the call fail, we just try to load the base filename...
     pass
 try:
     return dllType( name, mode )
 except Exception as err:
     err.args  = (name,fullName)
     raise

How to fix this?

i am using : System Version: macOS 12.1 (21C52) Kernel Version: Darwin 21.2.0

CodePudding user response:

I think you were on the right track. You please change your below code:

 fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'#None this path was edited it was none before , LOCALCHANGES
 try:
     fullName = util.find_library( name )

to

 fullName = None
 try:
     fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'

Hope this will help you.

  • Related