python-real different from python interpreter

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
$ ./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:
./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.

./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.

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

questions

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

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