# Using Slicer and Slicer Modules from Command-Line

**URL:** <https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162>\
**Category:** Support\
**Created:** [August 24, 2019, 6:28pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162 "2019-08-24T18:28:13Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 28, 2019, 9:34pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/21 "2019-08-28T21:34:35Z")

</div>

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

> [@matt-warkentin](#):
>
> Does this mean the `plastimatch` binary is buried somewhere inside the Slicer file tree?

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.

---

<div class="post-metadata">

**Author:** ![matt-warkentin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matt-warkentin/32/4962_2.png) [@matt-warkentin](https://discourse.slicer.org/u/matt-warkentin)\
**Post date:** [August 28, 2019, 9:49pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/22 "2019-08-28T21:49:57Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 28, 2019, 11:06pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/23 "2019-08-28T23:06:44Z")

</div>

> [@matt-warkentin](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![matt-warkentin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matt-warkentin/32/4962_2.png) [@matt-warkentin](https://discourse.slicer.org/u/matt-warkentin)\
**Post date:** [August 28, 2019, 11:48pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/24 "2019-08-28T23:48:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 29, 2019, 12:01am UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/25 "2019-08-29T00:01:03Z")

</div>

> [@pieper](#):
>
> maybe there’s a fix such that `PythonSlicer` can import the same packages without needing the launcher.

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?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 29, 2019, 12:59pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/26 "2019-08-29T12:59:05Z")

</div>

> [@lassoan](#):
>
> @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 ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 29, 2019, 1:27pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/27 "2019-08-29T13:27:22Z")

</div>

> [@jcfr](#):
>
> What make you think it is not the case ? What would be a small example to reproduce the problem ?

The problem/inconsistency is this:

> [@pieper](#):
>
> Running `PythonSlicer` without the launcher I cannot `import radiomics` but with the launcher I can (on linux nightly from 2019-08-22).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 29, 2019, 7:58pm UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/28 "2019-08-29T19:58:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [August 14, 2020, 3:17am UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/29 "2020-08-14T03:17:32Z")

</div>

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

```auto
$ ./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

```auto
$ ./Slicer --launch gnome-terminal

```

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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 14, 2020, 3:48am UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/30 "2020-08-14T03:48:09Z")

</div>

Everything should still work the same way.

> [@kayarre](#):
>
> and this doesn’t appear to work anymore

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](https://www.slicer.org/wiki/Documentation/Nightly/FAQ/General#Where_can_I_download_Slicer.3F)).

---

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [August 14, 2020, 3:54am UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/31 "2020-08-14T03:54:08Z")

</div>

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.

```auto
~/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

```

```auto
~/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

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 14, 2020, 4:04am UTC](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162/32 "2020-08-14T04:04:06Z")

</div>

Try specifying `PYTHONNOUSERSITE=1` environment variable. If it does not help then check out discussion in [this topic](https://discourse.slicer.org/t/cant-start-slicer-on-linux-on-one-machine/8175/21), maybe it helps.

[Previous page](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162.md?page=1)
