Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Getting an error when calling load more than once #2078

Copy link
Copy link
@bendhayer

Description

@bendhayer
Issue body actions

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 call load("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.

from pythonnet import load

load("coreclr")
load("coreclr")
  • If there was a crash, please include the traceback here.
Failed to initialize pythonnet: System.InvalidOperationException: This property must be set before runtime is initialized
   at Python.Runtime.Runtime.set_PythonDLL(String value) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Runtime.cs:line 27
   at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Loader.cs:line 23
   at Python.Runtime.Runtime.set_PythonDLL(String value) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Runtime.cs:line 27
   at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Loader.cs:line 23Traceback (most recent call last):
  File "/home/gitlab-runner/test_pythonnet/test.py", line 4, in <module>
    load("coreclr")
  File "/home/gitlab-runner/test_pythonnet/.venv/lib/python3.11/site-packages/pythonnet/__init__.py", line 144, in load
    raise RuntimeError("Failed to initialize Python.Runtime.dll")
RuntimeError: Failed to initialize Python.Runtime.dll

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.