使用pyopengl在mac m1上加载OpenGL库时出现问题

7gyucuyw  于 2022-11-04  发布在  Mac
关注(0)|答案(1)|浏览(226)

我有这些进口货

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

错误为:

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

错误堆栈:

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:

已尝试通过以下答案进行修复:Unable to import opengl.gl in python on macos
出现错误的site-packages/OpenGL/platform/ www.example.com文件的内容ctypesloader.py如下所示:

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

如何解决这个问题?
我正在使用:系统版本:macOS 12.1(21 C52)内核版本:达尔文21.2.0

rryofs0p

rryofs0p1#

我想你是在正确的轨道上。你请改变你的下面代码:

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

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

希望这对你有帮助。

相关问题