I have manually built Slicer (at e17d2025) and when I package the project and install it, then I noticed I’m unable to run SlicerPython.exe/PythonSlicer.exe. It is able to run from my build tree though. I did not have any python paths present in any sys path environment variable at time of build.
PS C:\S5R\python-install\bin> ./SlicerPython.exe
Python 3.6.7 (default, Jan 6 2020, 07:41:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Is there something about LauncherSettings that are messed up in the packaged/installed version?
The PythonSlicer/SlicerPython appears to be working in the most recent nightly.
PS C:\Users\sam.horvath\AppData\Local\NA-MIC\Slicer 4.11.0-2020-01-05\bin> ./SlicerPython.exe
Python 3.6.7 (default, Jan 5 2020, 23:24:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
PythonSlicer in latest preview release (Slicer 4.11.0-2020-01-05) install works well for me, too. What do you mean that you are unable to run it? Is it a custom application or a factory build of Slicer?
.ini file content is completely different for build and install tree, so it is possible that something only works in one but broken in the other. Most Python launcher settings are taken from the main application’s settings (designated by additionalSettingsFilePath field).
As I attempted to detail above in the powershell output, it just exits out automatically when I try to run it.
Is it a custom application or a factory build of Slicer?
It is not a Slicer Custom App. I just cloned, configured Slicer and used the default configure options and built. Then I proceeded to package this Slicer and install.
Does factory-built Slicer installations work? Do you see any difference in the generated .ini files in factory-built and self-built versions in the install tree?
I downloaded the nearly identical Slicer-4.11.0-2019-12-06-win-amd64 generated by the factory machine and running ./SlicerPython.exe does actually work.
I checked for differences between factory and my package of SlicerPythonLauncherSettings, PythonSlicerLauncherSettings, SlicerDesignerLauncherSettings, and SlicerLauncherSettings. The only difference was in SlicerLauncherSettings where mine specified revision=e17d202 instead of revision=28668.
PS C:\Users\JamesButler\AppData\Local\NA-MIC\Slicer 4.11.0-2019-12-06\bin> ./python-real.exe
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x000025c4 (most recent call first):
PS C:\Users\JamesButler\AppData\Local\NA-MIC\Slicer 4.11.0-2019-12-06\bin>
So, this looks like an error with the Python build itself, not the launcher. Things are clearly missing from the install tree .The factory version gives the python prompt for me:
PS C:\Users\sam.horvath\AppData\Local\NA-MIC\Slicer 4.11.0-2020-01-05\bin> ./python-real.exe
Python 3.6.7 (default, Jan 5 2020, 23:24:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
This is very odd. Running ./python-real.exe without the launcher is expected to fail with No module named 'encodings' message (since it cannot find very basic Python libraries).
I was able to reproduce the problem on my computer - my builds use CTKAPPLAUNCHER\bin\CTKAppLauncherW.exe as SlicerPython.exe and PythonSlicer.exe. This is incorrect, because CTKAppLauncherW.exe is a Windows GUI application and the CTKAppLauncher.exe console application should be used as launcher instead.
Python should be always configured with CTKAppLauncher executable - regardless of the main application is a console or GUI application. I’ll push a fix.