- Notifications
You must be signed in to change notification settings - Fork749
Closed
Description
Environment
- Pythonnet version: 3.0.1
- Python version: 3.11.1
- Operating System: Windows & Linux
- .NET Runtime: net6.0, net7.0
Details
- Describe what you were trying to get done.
I have 2 libraries that are packaging some C# code with pythonnet as a dependency so that they can be used from Python without issues. In both libraries I callload("coreclr")
in the__init__.py
. When a user try to load both libraries at the same time pythonnet throw an exception. It wasn't happening with pythonnet version 2 so I suspect that this is a bug of pythonnet version 3.
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
frompythonnetimportloadload("coreclr")load("coreclr")
- If there was a crash, please include the traceback here.
Failedtoinitializepythonnet:System.InvalidOperationException:ThispropertymustbesetbeforeruntimeisinitializedatPython.Runtime.Runtime.set_PythonDLL(Stringvalue)in/tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Runtime.cs:line27atPython.Runtime.Loader.Initialize(IntPtrdata,Int32size)in/tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Loader.cs:line23atPython.Runtime.Runtime.set_PythonDLL(Stringvalue)in/tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Runtime.cs:line27atPython.Runtime.Loader.Initialize(IntPtrdata,Int32size)in/tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Loader.cs:line23Traceback (mostrecentcalllast):File"/home/gitlab-runner/test_pythonnet/test.py",line4,in<module>load("coreclr")File"/home/gitlab-runner/test_pythonnet/.venv/lib/python3.11/site-packages/pythonnet/__init__.py",line144,inloadraiseRuntimeError("Failed to initialize Python.Runtime.dll")RuntimeError:FailedtoinitializePython.Runtime.dll