pyglet: Import Error: Can't find framework %s." % path
When I try to run from pyglet.gl import *
The code line 262 tries to find OpenGL inside the directory /System/Library/Frameworks/OpenGL.framework.
https://github.com/pyglet/pyglet/blob/d563b7a001506758a77fde035c22c786476d0093/pyglet/lib.py#L262
The function return None which in turn raise ImportError("Can't find framework %s." % path) # on line 283
System Information
OS: Mac OS Big Sur Public 11.0 Beta (20A5354i).
Darwin Akarshs-MacBook-Pro.local 20.0.0 Darwin Kernel Version 20.0.0: Fri Aug 14 00:25:13 PDT 2020; root:xnu-7195.40.44.151.1~4/RELEASE_X86_64 x86_64
Tree structure of the dir /System/Library/Frameworks/OpenGL.framework in my system.
akarshjain@Akarshs-MacBook-Pro /System/Library/Frameworks/OpenGL.framework tree
.
├── Libraries -> Versions/Current/Libraries
├── Resources -> Versions/Current/Resources
└── Versions
├── A
│ ├── Libraries
│ │ ├── 3425AMD
│ │ │ ├── CVMCompiler
│ │ │ └── libCoreVMClient.mono.dylib
│ │ ├── 3600
│ │ │ ├── CVMCompiler
│ │ │ └── libCoreVMClient.mono.dylib
│ │ ├── CVMCompiler
│ │ ├── CVMServer
│ │ ├── DumpGPURestart
│ │ ├── ReportGPURestart
│ │ ├── libGLVMPlugin.dylib
│ │ ├── libGLVMPlugin31001.dylib
│ │ ├── libGLVMPlugin3802.dylib
│ │ └── libGLVMPlugin3902.dylib
│ ├── Resources
│ │ ├── BridgeSupport
│ │ │ └── OpenGL.bridgesupport
│ │ ├── CVMSPlugin.exp
│ │ ├── CVMSPluginAll.exp
│ │ ├── CVMSPluginNoExec.exp
│ │ ├── GLByteCodes.arm64.bc
│ │ ├── GLByteCodes.x86_64.bc
│ │ ├── GLEngine.bundle
│ │ │ └── GLEngine
│ │ ├── GLRendererFloat.bundle
│ │ │ └── GLRendererFloat
│ │ ├── Info.plist
│ │ ├── cvmsConfig.plist
│ │ └── version.plist
│ └── _CodeSignature
│ └── CodeResources
└── Current -> A
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 33 (11 by maintainers)
Links to this issue
Commits related to this issue
- Fix issue #274 (#284) * Inital changes completed * Added back import for ctypes.util * Updates macOS release info Co-authored-by: jerekshoe <jerek.shoemaker@ennovar.wichita.edu> — committed to pyglet/pyglet by benmoran56 4 years ago
- Fix issue #274 (#284) * Inital changes completed * Added back import for ctypes.util * Updates macOS release info Co-authored-by: jerekshoe <jerek.shoemaker@ennovar.wichita.edu> — committed to pyglet/pyglet by benmoran56 4 years ago
- Bump pyglet version to support OpenGL in BigSur Apple went and did some stuff in BigSur to the way OpenGL is present in the filesystem which BigBroke pyglet which broke some gyms. (Specifically, `cla... — committed to liavkoren/gym by liavkoren 4 years ago
I have also been trying to fix these errors while trying to render in Gym (on Big Sur, pyglet 1.5.0, system Python 3.8.2) and I found that two fixes are needed:
def find_framework(path): return '/System/Library/Frameworks/OpenGL.framework/OpenGL'As @MichaelFeng1997 says, a different error then appears. I see an error when trying to load things from the AppKit framework:
ValueError: dlsym(RTLD_DEFAULT, NSEventTrackingRunLoopMode): symbol not foundappkit = cdll.LoadLibrary('/System/Library/Frameworks/AppKit.framework/AppKit')It seems that this change in loading from dynamic libraries is affecting other repos. and may affect other places in the pyglet codebase (from a quick search of util.find_library), but I don’t think it’ll take too long to fix these. I’m not sure how to have a fix with backward compatibility though.
Hope that helps anyone with the same problem!
Most likely it’s going to be the same in stable Big Sur release. So the issue should be addressed, I guess.
Is there any hack to solve this issue as of now ?
Just found a quick fix : go into pyglet/lib.py file and look for the
find_framework(path)function. Then comment the body of the function and just return the path to OpenGL.framework :I’m also facing the same issue using the official release of macOS Big Sur.
I’m trying to run env.render() from Gym OpenAI environments but I get this error :
I checked /System/Library/Frameworks/OpenGL.framework and everything seems to be good in the folder. Can’t find any solutions…
I am facing the same issue. Using the official release of macOS Big Sur.
@ulfarsson I believe that message is normal. I’ve always had it at least
Hardcoding the path can work for the time being, but once the CPython fixes make their way out pyglet should work again without any hacks (point release due out soon). Lets leave this issue open until that starts happening.
If anyone wants to check if their Python is working, try this simple test:
If it returns
None, it doesn’t have the fix. Currently, only the OSX system bundled Python is working at the moment.For reference, the CPython issue can be found here: https://bugs.python.org/issue41100
@ebolotin6 If you can’t wait, you can do what ‘geekstor’ said. This worked for me on Big Sur. You probably need to run ‘XQuartz’ while you run your Python program.
Thank you so much! I just changed the “def find_framework(path)” and now everything works just like before (no additional error).
We have a pull request open to fix this: https://github.com/pyglet/pyglet/pull/284
I’ve just been waiting to get confirmation that it doesn’t break older OSX versions. If anyone here has access to previous releases, and can test it, then we can get that merged in.
@ulfarsson Make sure to update to the latest pyglet release (v1.5.10).
If I run the code snipped you posted @benmoran56 I get
However, when running
I get the error
I’m running this on macOS Big Sur with Python3 from Homebrew
I’ve merged in the fix from Jerekshoe, which will be in the next point release. My understanding is that this should fix things ONLY for the system Python in Big Sur. Other Python releases will need to wait for upstream CPython fixes.
@ebolotin6 sorry for not getting back to you sooner, but luckily some others have been able to test.