I’m working with Slicer 4.7.0 (see attached screenshot for full details) and I just set a custom Python module path in Edit > Applicaition Settings > Modules. After restarting Slicer I can import my custom module but as soon as the Python console opens I see the following error/warning message:
SystemError: /Users/kitware/Dashboards/Nightly/Slicer-0-build/Python-2.7.13/Objects/classobject.c:521: bad argument to internal function
My custom module script works so I’m not sure whether this is a big problem. Just thought you guys might know what’s going on. Loading a custom Python script seems pretty basic functionality so I was surprised that this error message appears
Hi Ralph -
What does your scripted module use? Any binary packages that aren’t built against the Slicer build of python can cause trouble for a binary download of Slicer.
Also a mix of “old style” and “new style” python classes can lead to this message (see the discussions linked below).
If it’s not that can you share the code for an example that leads to the issue? The simplest code that leads to the message would be the most useful.
My code is no secret. It’s just a file called test_me.py which contains a single method def test_me() that prints “test me”. Can’t get any simpler than that .
By the way, the function works. It prints out “test me” like it’s supposed to. I was just wondering about the error message.
Hi Ralph -
Ah, well, then maybe your code is ‘too simple’ to work that way ; )
We use the term “module” in Slicer to refer to something pretty specific that implements GUI and Logic classes. That’s what the Module Paths in the settings refers to.
If what you want to do is set up the code like a test_me function to run every time Slicer starts, you can set up a .slicerrc.py file in your home directory as described here:
Hope that helps!
Ralph, you can put your custom (non-Slicer) Python packages in subdirectories within the folder that you specify in “Additional module paths”.
Ok, that was not clear from the what was written at the beginning of the documentation at https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository. It mentioned "save the .py file to a directory and add the directory to the additional module paths in the Slicer application settings. No mention of a module being anymore than a regular Python module.
Anyway, thanks for looking into this!
Aha, I see - okay, I updated the wiki page to clarify:
Let us know if other things aren’t clear.