Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to generate stub file for my package #237

Open
zhang-qiang-github opened this issue Dec 29, 2024 · 1 comment
Open

Failed to generate stub file for my package #237

zhang-qiang-github opened this issue Dec 29, 2024 · 1 comment

Comments

@zhang-qiang-github
Copy link

The pybind11 code to generate module is:

class A
{
public:
	A()
	{

	}

	/**
	* @brief explanation from c++
	*/
	int Add(int a, int b)
	{
		return a+b; 
	}

};

PYBIND11_MODULE(module, m) {


    m.doc() = "My Library Python Bindings";

	py::class_<A>(m, "A")
		.def(py::init<>())
		.def("Add", &A::Add, "explanation from pybind");

}

And it successfully generated a python module, and I can import it:

image

Then, I want to generate the stub file for this module. I have tested the pybind11-stubgen, and it works:
image

However, it failed when generate stub file for my-self package:
image

How should I use the pybind11-stubgen?

@ax3l
Copy link

ax3l commented Jan 7, 2025

I would double check you are using the same Python interpreter for your pybind11-stubgen and your project module.

It looks to me like your pybind11-stubgen Python interpreter is the one in your Anaconda3 environment, while you installed your module into your system Python 3.9.20 environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants