I just started with pybind11 and I wanted to try the minimal example they provide on their page.
#include <pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
PYBIND11_MODULE(example, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &add, "A function that adds two numbers");
}
I am using visual studio 2022 and I can compile the solution without problem as a dll. This gives me inside the directory x64/Debug
the following files
example.dll
example.exp
example.lib
example.pdb
I then go inside the x64/Debug
folder and and run python 3.12 (the same version as I used in pybind11), but when I do
>>> import example
I get the following
>>> import example
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'example'
What am I doing wrong?