Error importing module created with swig

I am new to python.
I wrote few wrappers using swig for other people an they always worked.
I am now trying to make one using python 3.39

I am using swig 4.0.2 and visual studio 2015.

The module name that is generated is called

But when I try to import it, the command prompt simply exit silently.
I try to run it with python_d and I get this error.

ModuleNotFoundError: No module named _newtonPy

When I search for info about that error, it says that possible cause is a dependency is missing, but that module does not has any dependency.

Both files and _newtonPy.pyd
Are in the same sub directory.

I do not know why this happens.
If any one know, please tell me.

I have some more info.

I renamed the dll after it was build from
NewtonPy.dll to newtonPy.pyd
And that did not work.

But when changing the extension of the dll from
.dll to .pyd

Now it works.

So it seems the loader match the name with some internal name inside the generated file.

But in anyway. This problem is now solved.

Just in case anyone has the same issue.
The answer is to change the extension in visual studio


Actually I take my last comment back.

Changing the extension in visual studio does not fixes the bug.

What happens was that I made a simple module that just add two number in python not cpp to see if I can import it from another module like swig does, and it does works for files written in python.

It fail to load files that are compiled dlls, whether the extension pyd was added by the compiler or by renaming the dll.

I had the pyd extension from the documentation
Chapter 4 building c and c++ extension
It does say that to be importance the library must be available on PYTHONPATH and that must have must be name after the module.

I do not know what PythonPath is and also the generated library prepend an underscore to the name, I can’t change that.

Had the way of importing cpp dll changed?
Is so can someone point me to the doc.

I have not idea what else is wrong, I am following these steps straight from the tutorial.

Any help will be appreciated

Thank you.