Skip to content
Discussion options

You must be logged in to vote

Okay fixed. The issue was that pybind11::float_ and friends require that the Python interpreter be initialized on the C++ side if you are testing your pybind11 code within C++ only and not via python calls into your C++ module. In my simple test I added a pybind11::scoped_interpreter variable.

This was a somewhat costly gotcha. I suggest this be made clear in this section of the docs. I will open a PR.

  #include <pybind11/embed.h>
  ...
  
  pybind11::scoped_interpreter guard{};
  pybind11::object obj = pybind11::float_(0.f);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by henryiii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant