When I add module path, unexpected errors have occured - "No module named ****"

I use ExtensionWizard to create a loadable module, and then use Cmake & Visual Studio to build it.
Lastly, I add its path to Additional module paths in Slicer Setting.
But, when I restart 3DSlcier,there are some errors in Python Interactor,like:

No module named vtkSlicerIGS_dev1ModuleLogicPython
No module named qSlicerIGS_dev1ModuleWidgetsPythonQt
I really don’t know why.
I’d appreciate it if anyone can help me solve the problem.

File name must exactly match the module class name.

I’m sure the file name exactly matches with the module classname.
They are all named by ‘IGS_dev1’.
I also make another try, and test a scripted module. It is OK.
So, I really don’t know why this error just occures in loadable module.

What directories have you added to the additional module paths?

lassoan, it’s really kind of you.
Here, I introduce more detailed information about the error.
Looking forward to your reply.

Which Slicer version did you build?
Did you try to load the module into the Slicer version that you built?
Why your module build tree is inside a Slicer-build tree? (D:\Slicer4D\Slicer-build)
Do you have any errors when you build your module?
Do you have module logic and widget classes?
If you build an existing extension (such as https://github.com/SlicerHeart/SlicerHeart) do you get similar errors?

On windows, simply adding module path is not enough to have the environment updated.

Waiting we address issue #4183, I think possible way around are to:


  • update PATH and PYTHONPATH before starting Slicer

On Windows we always just add the Debug/Release directory to the additional module paths in Slicer application settings. I don’t recall ever seeing this error. Is updating Python paths a new requirement?

No. This was a general remarks about paths.

Since the extension we are talking about doesn’t have any dependencies (beside of Slicer), you are right it should just work.

I see, thanks.

For extensions that depend on other extensions, the generated “additional launcher settings” ini file takes care of all Python paths (it recursively collects all necessary paths and puts it into the ini file). I’ve implemented this 1-2 months ago.

@lassoan @jcfr
Thank you very much.
I have solved the problem in another way.
I adjusted my file path of MyExtension from D:/Slicer4D/Slicer-build/MyExtension to D:/MyExtension.
Luckily,the extension/module worked.
Though I don’t know why it works, I guess there maybe a limited length for file path in windows OS.

Slicer 4.7.0
yes, I haved tried.
I am sorry that I didn’t obey the suggestion that official manual give.
No, the building process of Cmake and Visual Studio is OK.
yes, I’m sure I have logic and widget classes.
I ever built an extension - Slicer-IGT, but no errors occured.

1 Like