0

I have a conda environment with python 3, pyopengl, and pyqtgraph installed. Running import OpenGL works with no issue, but when I try to run the pyqtgraph examples with python -m pyqtgraph.examples, most of the examples work, but if I run one of the 3D examples requiring OpenGL, I get the following error:

Using PyQt5 (default graphics system)
Traceback (most recent call last):
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 35, in GL
    return ctypesloader.loadLibrary(
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/ctypesloader.py", line 45, in loadLibrary
    return dllType( name, mode )
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/ctypes/__init__.py", line 381, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: ('dlopen(OpenGL, 10): image not found', 'OpenGL', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/pyqtgraph/examples/GLIsosurface.py", line 12, in <module>
    import pyqtgraph.opengl as gl
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/pyqtgraph/opengl/__init__.py", line 1, in <module>
    from .GLViewWidget import GLViewWidget
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 2, in <module>
    from OpenGL.GL import *
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/GL/__init__.py", line 3, in <module>
    from OpenGL import error as _error
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/error.py", line 12, in <module>
    from OpenGL import platform, _configflags
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/__init__.py", line 35, in <module>
    _load()
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/__init__.py", line 32, in _load
    plugin.install(globals())
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 92, in install
    namespace[ name ] = getattr(self,name,None)
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 14, in __get__
    value = self.fget( obj )
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 62, in GetCurrentContext
    return self.CGL.CGLGetCurrentContext 
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 14, in __get__
    value = self.fget( obj )
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 45, in CGL
    def CGL(self): return self.GL
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 14, in __get__
    value = self.fget( obj )
  File "/usr/local/Caskroom/miniconda/base/envs/mcdermott3/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 41, in GL
    raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'dlopen(OpenGL, 10): image not found', 'OpenGL', None)

Any ideas how to fix this? If it is relevant I am running this in Mac OS Big Sur and installed everything with conda.

EDIT: I just found this about a similar problem but still have no idea what to do about it.

roboguy222
  • 157
  • 13

1 Answers1

0

From an email with Paul McCarthy:

"This is probably due to a change in Big Sur which affects the way that Python looks up shared libraries, which caused PyOpenGL to break, actually unrelated to the FSLeyes github issue you found. Big Sur now removes certain shared dylib files from the file system, and instead places them into an in-memory cache. It then intercepts dlopen calls which refer to the full file path, and loads the files from the cache. This is incompatible with the method that Python previously used to load shared libraries on macOS. The Python folk have already implemented a solution, but I'm not sure if the fix has been released yet (and I think it is only being released for Python 3.8 and above)."

This link has some fixes to this problem.

roboguy222
  • 157
  • 13