Почему import clr выдает исключение после установки pythonnet?Python

Программы на Python
Anonymous
Почему import clr выдает исключение после установки pythonnet?

Сообщение Anonymous »

Я пытаюсь получить доступ к DLL .NET из Python с помощью Pythonnet. DLL содержит библиотеку, преобразованную в .netStandard2. Однако я получаю сообщение об ошибке при простой попытке импортировать clr. Могу ли я получить какие-либо указания относительно того, почему я не могу импортировать clr и как получить доступ к функциям в dll из Python?
Я использую Python 3.10.12
В моем 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
Это моя текущая моно-версия:

Код: Выделить всё

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
Однако, когда я пытаюсь просто запустить «import clr», появляется следующая ошибка:

Код: Выделить всё

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).
Я пробовал просматривать документацию и т. д., но не знаю, как обойти это исключение.

Подробнее здесь: https://stackoverflow.com/questions/788 ... -installed

Вернуться в «Python»