Skip to content

[BUG]: Can't use PYBIND11_NUMPY_DTYPE with subinterpreters #5781

Open

Description

@henryiii

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

3.0.0

Problem description

Registering a DTYPE fails in subinterpreters because the DTYPE is already registered. Any thoughts on how to make this subinterpreter safe?

ImportError: NumPy: dtype is already registered

Edit: I think numpy may not work in subinterpreters; if I suppress this error when it's already loaded, then it looks like numpy throws an error when importing. So it might not be very important to solve until numpy supports subinterpreters.

Reproducible example code

PYBIND11_NUMPY_DTYPE(weighted_sum, value, variance);

Is this a regression? Put the last known working version here if it is.

Not a regression

Activity

  1. added
    triage
    on Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions