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

"Issues" on MacOS 11 #1068

Open
mschottdorf opened this issue Jan 22, 2021 · 6 comments
Open

"Issues" on MacOS 11 #1068

mschottdorf opened this issue Jan 22, 2021 · 6 comments

Comments

@mschottdorf
Copy link

mschottdorf commented Jan 22, 2021

Hi all,

I installed Phy on MacOS 11, and stumbled into an annoying error. As others might have experienced this problem as well, I thought it could be useful to document the solution:

When trying to run phy, it throws the error: ImportError: ('Unable to load OpenGL library', 'dlopen(OpenGL, 10): image not found', 'OpenGL', None). This is not an issue with Phy per se; the same error happened when trying in a python window from OpenGL import GL.

The problem is a OpenGL complication of MacOS 11. pyOpenGL tries to find OpenGL via ctypes, and fails.

This is the solution: One can edit the PyOpenGL file OpenGL/platform/ctypesloader.py and tell it exactly where openGL is located. i.e. replace line fullName = util.find_library( name ) with fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'

This solved the problem for me.

-Manuel

@HammadFKhan
Copy link

Thank you for this tips. It works for me as well!

@czuba
Copy link
Contributor

czuba commented Jun 9, 2021

Worked for me too. Thanks @mschottdorf

Instance of ctypesloader.py found in my phy2 env (python3.7) included this half-workaround:

    if isinstance( dllType, ctypes.LibraryLoader ):
        dllType = dllType._dlltype
    if sys.platform.startswith('linux'):
        return _loadLibraryPosix(dllType, name, mode)
    else:
        return _loadLibraryWindows(dllType, name, mode)


def _loadLibraryPosix(dllType, name, mode):
    """Load a given library for posix systems

    The problem with util.find_library is that it does not respect linker runtime variables like
    LD_LIBRARY_PATH.
    # ...yadda yadda yadda...
    """

So it appears MacOS 11 users weren't the only ones getting stuck here.

Continuing to the _loadLibraryWindows method was also erroring on MacOS, so I just hacked in a _loadLibraryMacOs alternative following @mschottdorf's suggestion:

    if isinstance( dllType, ctypes.LibraryLoader ):
        dllType = dllType._dlltype
    if sys.platform.startswith('linux'):
        return _loadLibraryPosix(dllType, name, mode)
    elif sys.platform.startswith('darwin'):
        return _loadLibraryMacOs(dllType, name, mode)
    else:
        return _loadLibraryWindows(dllType, name, mode)

&

def _loadLibraryMacOs(dllType, name, mode):
    """Load a given library for MacOS 11(+) systems with hardcoded OpenGL path

    returns the ctypes C-module object
    """
    name = '/System/Library/Frameworks/OpenGL.framework/OpenGL'
    try:
        return dllType( name, mode )
    except Exception as err:
        err.args += (name, 'MacOS_hardcoded')
        raise

...not that its particularly better/elegant/necessary, but in any case curious that something that seems so elemental would be hanging like this.

@Elliott365
Copy link

I have a fresh install of phy2 and encountered the same error. When trying the solution listed by @mschottdorf I encountered this error

ImportError: ('Unable to load OpenGL library', 'dlopen(/System/Library/Frameworks.OpenGl.framework/OpenGL, 10): image not found', '/System/Library/Frameworks.OpenGl.framework/OpenGL', '/System/Library/Frameworks.OpenGl.framework/OpenGL')

@czuba
Copy link
Contributor

czuba commented Jun 18, 2021

@Elliott365 Check your string.
“Gl” ~= “GL” 🧐👍🏼

@Elliott365
Copy link

much appreciated. Now I get:

Error: Invalid value for 'PARAMS_PATH': Path 'params.py' does not exist.

when running phy template-gui params.py

@HammadFKhan
Copy link

HammadFKhan commented Jun 18, 2021 via email

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

4 participants