Is there a way to modify sys.executable to PythonSlicer.exe when launching python outside Slicer (ie when launching directly from PythonSlicer.exe)? So that I could run PythonSlicer.exe -c "import sys; print(sys.executable)" and see PythonSlicer.exe as output
It is possible to set PYTHONSTARTUP env var and run python script every time interpreter started.
But this is not applicable when running code in the way: python -c "import sys; print(sys.executable)".
in this case we will see python-real.exe anyway
When using PythonSlicer, setting PYTHONSTARTUP works as expected.
When using Slicer, there are no support for PYTHONSTARTUP environment variable because Slicer application embeds the python library and the logic handling PYTHONSTARTUP (specific to the python interpreter) is not considered.
In the case of the Slicer application, you should instead considering using the Application Startup File
To provide a more targeted answer, could you provide more details ? What are you trying to achieve ?