Using Slicer and Slicer Modules from Command-Line

Plastimatch contains a wide variety of features. We only enable building of the core radiation therapy features.

It is not buried at all but nicely linked into Slicer modules and a few command-line applications (as far as I remember, statically). You can run command-line applications using Slicer launcher, without starting the Slicer application GUI.

@lassoan I didn’t mean to be snide with my “buried” comment; I just meant located somewhere in the internal file structure.

Based on the previous discussion with @pieper, I was under the impression that since I am running on Mac OS, that the Slicer launcher wouldn’t work as anticipated? Or is this meant to be resolved when I upgrade to a more recent build?

No, this wouldn’t have changed - for mac we don’t use the installer because there are constraints about how apps need to be structured (e.g. to allow for signing the binaries). The open question is how environments are shared between Slicer and PythonSlicer - maybe there’s a fix such that PythonSlicer can import the same packages without needing the launcher.

1 Like

These installation technicalities are definitely not something I have any real knowledge of. But yes, I agree that your proposed fix would indeed be nice, if possible.

PythonSlicer inherits settings from the ini file of Slicer, starting from 4.10.2 or so. @jcfr why do you think there could be a difference between Slicer and PythonSlicer on Mac?

On MacOS, Slicer.app (or the executable found in Slicer.app/Contents/MacOS) is not a launcher but the actual executable. That said, env. variables are read from a launcher settings file (to be consistent across platform).

PythonSlicer on all platform (including macOS) are inheriting settings from SlicerLauncherSettings.ini

What make you think it is not the case ? What would be a small example to reproduce the problem ?

The problem/inconsistency is this:

The reason is that PythonSlicer doesn’t add the python site-packages paths from the installed extensions so they can’t be imported.

Using an old version of Slicer I was able to use the following command with KDE

$ ./Slicer --launch konsole &

on nightly release
I am now using linux mint with gnom and this doesn’t appear to work anymore using something like

$ ./Slicer --launch gnome-terminal

did this feature go away or what am I doing wrong, or is it related to nightly?

Everything should still work the same way.

What do you mean by doesn’t appear to work? What happens? Do you see any error message?

Can you launch other executables?
Do other options work (you can get a list by calling --help)?

If you install an earlier Slicer Preview Release then does it work better? (you can download them by specifying additional arguments on the download page).

ok good, needed to make sure I eliminated any issues between chair and keyboard.
here are a couple of the attempts. I haven’t tried with konsole as I don’t have a kde environment close by.

~/tools/Slicer-4.11.0-2020-08-12-linux-amd64/Slicer --launch gnome-terminal
Failed to import the site module
Traceback (most recent call last):
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/bin/../lib/Python/lib/python3.6/site.py", line 553, in <module>
    main()
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/bin/../lib/Python/lib/python3.6/site.py", line 539, in main
    known_paths = addusersitepackages(known_paths)
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/bin/../lib/Python/lib/python3.6/site.py", line 282, in addusersitepackages
    user_site = getusersitepackages()
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/bin/../lib/Python/lib/python3.6/site.py", line 258, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/bin/../lib/Python/lib/python3.6/site.py", line 248, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/lib/Python/lib/python3.6/sysconfig.py", line 601, in get_config_var
    return get_config_vars().get(name)
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/lib/Python/lib/python3.6/sysconfig.py", line 550, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/lib/Python/lib/python3.6/sysconfig.py", line 421, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_linux_x86_64-linux-gnu
~/tools/Slicer-4.11.0-2020-08-12-linux-amd64/Slicer --launch terminator
  File "/home/sansomk/tools/Slicer-4.11.0-2020-08-12-linux-amd64/bin/../lib/Python/lib/python3.6/site.py", line 177
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

Try specifying PYTHONNOUSERSITE=1 environment variable. If it does not help then check out discussion in this topic, maybe it helps.