# Slicer parameters conflicts when adding "--load-file" and "--python-script"

**URL:** https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390
**Category:** Support
**Tags:** python
**Created:** [December 14, 2023, 8:16am UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390 "2023-12-14T08:16:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![derekcbr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/derekcbr/32/18793_2.png) [@derekcbr](https://discourse.slicer.org/u/derekcbr)
#### Post date: [December 14, 2023, 8:16am UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390/1 "2023-12-14T08:16:10Z")

</div>

Slicer.exe, “–python-code”, “print(‘Start Slicer from Blender!’)”, “–python-script”, startup\_slice\_script\_file  
When adding both “–load-file” and “–python-script”, “–load-file” will not be executed to load .mrb file, and it only executes “–python-script”. Is there a way of adding both parameters and make it working? Thanks.

---

<div class="post-metadata">

### Author: ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)
#### Post date: [December 15, 2023, 6:33am UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390/2 "2023-12-15T06:33:33Z")

</div>

I don’t think there is any `--load-file` flag, but i is true that something like

```bash
./Slicer --python-code "print('Hello from command-line')" /tmp/scene.mrb

```

will both load the file (first) and execute the provided python code (second), while

```bash
./Slicer --python-script /tmp/script.py /tmp/scene.mrb

```

won’t load the file `/tmp/scene.mrb`.

It seems that providing python script explicitly prevents the load of files:

> <https://github.com/Slicer/Slicer/blob/1d77e473abebc3b554d886614e2958adff34e38e/Base/QTCore/qSlicerCoreApplication.cxx#L1145-L1178>

### Moving forward

1. @pieper, @lassoan , is that an inconsistency that should be fixed?

2. @derekcbr, have you tried to load the scene using your python script? or a combination of python script and python code? e.g.,

```python
./Slicer --python-code "slicer.util.loadScene('/tmp/Scene.mrb')" --python-script /tmp/script.py 

```

---

<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: [December 15, 2023, 1:52pm UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390/3 "2023-12-15T13:52:47Z")

</div>

@RafaelPalomar - right, this is intentional. The idea is that if you specify a python script then the other command line arguments are made available as `sys.argv` in python.

---

<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: [December 15, 2023, 2:50pm UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390/4 "2023-12-15T14:50:25Z")

</div>

It would be helpful to describe this in the documentation. I had a look in the Slicer documentation but I did not find specification of command-line arguments for the appplication (only [examples in the script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#run-a-python-script-file-in-the-slicer-environment) and some [tips in the Python FAQ](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#what-is-the-python-console)).

Have I missed something or we should add a new documentation section for describing the frequently used command-line arguments (maybe around [here](https://slicer.readthedocs.io/en/latest/user_guide/settings.html#qt-built-in-command-line-options))?

---

<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: [December 15, 2023, 3:15pm UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390/5 "2023-12-15T15:15:23Z")

</div>

I agree, I don’t think these are documented beyond the brief message you get with `--help`

---

<div class="post-metadata">

### Author: ![derekcbr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/derekcbr/32/18793_2.png) [@derekcbr](https://discourse.slicer.org/u/derekcbr)
#### Post date: [December 16, 2023, 12:23am UTC](https://discourse.slicer.org/t/slicer-parameters-conflicts-when-adding-load-file-and-python-script/33390/6 "2023-12-16T00:23:30Z")

</div>

Thanks, quite helpful!
