1

I am trying to access a .NET DLL from python using pythonnet. The dll contains a library that has been converted to .netStandard2. However, I am getting an error when simply trying to import clr. Can I have some guidance as to why I am unable to import clr and how to access the functions within the dll from python?

I am using Python 3.10.12

I have the following packages and their associated versions installed in my venv.

cffi 1.16.0

clr-loader 0.2.6

pip 23.0.1

pycparser 2.22

pythonnet 3.0.3

setuptools 65.5.0

This is my current mono version:

Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           
        SIGSEGV:       normal
        Notification:  kqueue
        Architecture:  arm64
        Disabled:      none
        Misc:          softdebug 
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       preemptive
        GC:            sgen

However, when I try to just run "import clr" it gives me the following error:

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' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib' (no such file), '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called '/Library/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.dylib'

The above exception was the direct cause of the following exception:

RuntimeError: Failed to create a default .NET runtime, which would
                    have been "mono" on this system. Either install a
                    compatible runtime or configure it explicitly via
                    `set_runtime` or the `PYTHONNET_*` environment variables
                    (see set_runtime_from_env).

I have tried looking through documentation, etc. but am unsure how to work around this exception.

1
  • Did you find the issue in the end? Commented Jan 27 at 18:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.