# python-real different from python interpreter

**URL:** <https://discourse.slicer.org/t/python-real-different-from-python-interpreter/2496>\
**Category:** Development\
**Tags:** extensions-manager\
**Created:** [April 2, 2018, 8:17pm UTC](https://discourse.slicer.org/t/python-real-different-from-python-interpreter/2496 "2018-04-02T20:17:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 2, 2018, 8:45pm UTC](https://discourse.slicer.org/t/python-real-different-from-python-interpreter/2496/2 "2018-04-02T20:45:42Z")

</div>

Hi David,

Both `bin/python-real` and Slicer executable are expected to use the same python shared library.

Here is how you could execute both ensuring they use the expected library:

- for Slicer

```auto
$ ./Slicer-build/Slicer --python-code "import sys; print(sys.maxunicode)" --exit-after-startup --no-main-window --no-splash
65535

# the '-c' option is also supported

$ ./Slicer-build/Slicer -c "import sys; print(sys.maxunicode)" --no-splash
65535

```

- for python interpreter:

```auto
./python-install/bin/SlicerPython -c "import sys; print(sys.maxunicode)"
65535

```

As you can see, the `python-real` executable can not be started directly. Otherwise it will resolve its symbols against a python library available somewhere else on your system.

### launcher

`SlicerPython` is a convenience launcher allowing to set the environment. The same one is used to start Slicer.

```plaintext
./python-install/bin/SlicerPython --launcher-help
Usage
  SlicerPython [options]

Options
  --launcher-help Display help
  --launcher-version Show launcher version information
  --launcher-verbose Verbose mode
  --launch Specify the application to launch
  --launcher-detach Launcher will NOT wait for the application to finish
  --launcher-no-splash Hide launcher splash
  --launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
  --launcher-load-environment Specify the saved environment to load.
  --launcher-dump-environment Launcher will print environment variables to be set, then exit
  --launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
  --launcher-additional-settings Additional settings file to consider
  --launcher-ignore-user-additional-settings Ignore additional user settings
  --launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
  --launcher-generate-template Generate an example of setting file

```

Using `--launcher-show-set-environment-commands` you could conveniently update the current environment and then start python-real directly.

```plaintext
eval $(./python-install/bin/SlicerPython --launcher-show-set-environment-commands)
python-real -c "import sys; print(sys.maxunicode)"

```

### questions

> [@David\_Burns](#):
>
> Where is the actual python binary that the interactor uses?

Both the Slicer python interactor available in the application and `bin/python-real` are expected to use the same python library.

> [@David\_Burns](#):
>
> Can this issue be fixed in the next release?
> 
> (I am not familiar enough with the slicer build system to fix this problem myself)

Based on the information above, let us know if you are able to work out a solution.

Reading this topic may also be informative: [Slicer-Python Packages Use and Install - #2 by jcfr](https://discourse.slicer.org/t/slicer-python-packages-use-and-install/984/2)

---

_[View the full topic](https://discourse.slicer.org/t/python-real-different-from-python-interpreter/2496)._
