Skip to content

Cannot load library libmonosgen-2.0.dylib on Apple M1 #2000

@thomasnal

Description

@thomasnal

Environment

  • Pythonnet version: 3.0.1
  • Python version: 3.9.13
  • Operating System: Darwin Kernel Version 21.6.0
  • .NET Runtime: 6.0.402
  • Mono: 6.12.0.182

Details

  • Describe what you were trying to get done.

I want Python to call a method in C# library that was built on MacOS M1 with VisualStudioPro. The first step is to import clr and that fails.

import clr

Fails with the following error:

E   OSError: cannot load library '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib': dlopen(/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib, 0x000A): tried: '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib' (fat file, but missing compatible architecture (have (i386,x86_64), need (arm64e))), '/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/libmonosgen-2.0.1.dylib' (fat file, but missing compatible architecture (have (i386,x86_64), need (arm64e))).  Additionally, ctypes.util.find_library() did not manage to locate a library called '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib'
  • If there was a crash, please include the traceback here.
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/pythonnet/__init__.py:75: in _create_runtime_from_spec
    return clr_loader.get_mono(**params)
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/clr_loader/__init__.py:58: in get_mono
    impl = Mono(
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/clr_loader/mono.py:30: in __init__
    self._version = initialize(
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/clr_loader/mono.py:127: in initialize
    _MONO = load_mono(libmono)
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/clr_loader/ffi/__init__.py:46: in load_mono
    return ffi.dlopen(path_str, ffi.RTLD_GLOBAL)
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/cffi/api.py:150: in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/cffi/api.py:832: in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
../../../../.pyenv/versions/3.9.13/envs/my/lib/python3.9/site-packages/cffi/api.py:827: in _load_backend_lib
    raise OSError(msg)
E   OSError: cannot load library '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib': dlopen(/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib, 0x000A): tried: '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib' (fat file, but missing compatible architecture (have (i386,x86_64), need (arm64e))), '/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/libmonosgen-2.0.1.dylib' (fat file, but missing compatible architecture (have (i386,x86_64), need (arm64e))).  Additionally, ctypes.util.find_library() did not manage to locate a library called '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib'```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions