Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import tk3dv since OpenGL's location has changed in macOS Big Sur #4

Closed
apugoneappu opened this issue Feb 12, 2021 · 2 comments

Comments

@apugoneappu
Copy link
Contributor

apugoneappu commented Feb 12, 2021

In macOS Big Sur, the location of OpenGL has changed and thus the regular import does not work (on my system). I am checking if the issue has been fixed on newer python versions.
Current python version: 3.7.9

Related PR - python/cpython#21241

Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tk3dv
Traceback (most recent call last):
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/darwin.py", line 38, in GL
    mode=ctypes.RTLD_GLOBAL
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/ctypesloader.py", line 36, in loadLibrary
    return _loadLibraryWindows(dllType, name, mode)
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/ctypesloader.py", line 89, in _loadLibraryWindows
    return dllType( name, mode )
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/ctypes/__init__.py", line 364, 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 "<stdin>", line 1, in <module>
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/tk3dv/__init__.py", line 1, in <module>
    import tk3dv.common
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/tk3dv/common/__init__.py", line 8, in <module>
    import utilities, drawing, defines
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/tk3dv/common/./drawing.py", line 1, in <module>
    import OpenGL.GL as gl
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/GL/__init__.py", line 3, in <module>
    from OpenGL import error as _error
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/error.py", line 12, in <module>
    from OpenGL import platform, _configflags
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/__init__.py", line 36, in <module>
    _load()
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/__init__.py", line 33, in _load
    plugin.install(globals())
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 97, in install
    namespace[ name ] = getattr(self,name,None)
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 15, in __get__
    value = self.fget( obj )
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/darwin.py", line 62, in GetCurrentContext
    return self.CGL.CGLGetCurrentContext
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 15, in __get__
    value = self.fget( obj )
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/darwin.py", line 45, in CGL
    def CGL(self): return self.GL
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 15, in __get__
    value = self.fget( obj )
  File "/Users/apoorve/anaconda3/envs/adven/lib/python3.7/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)
@apugoneappu
Copy link
Contributor Author

A temporary fix I found was to change a line in the file OpenGL/platform/ctypesloader.py from

fullName = util.find_library( name )

to

fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'

For my Anaconda python, the ctypesloader.py file was located in /Users/apoorve/anaconda3/envs/adven/lib/python3.7/site-packages/OpenGL/platform/ctypesloader.py.

Source - StackOverflow Solution

@apugoneappu
Copy link
Contributor Author

apugoneappu commented Feb 12, 2021

@drsrinathsridhar I feel it would be good to document this issue. Is there any place where documentation is being made?

Update - I added a new Issues section to the Readme and linked to this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant