There seems to ab a problem with the org.mitk.gui.qt.python Python pligin.
Basically, it compiles just fine, but when trying to load (both in Release and Debug mode) it generates (and displays instead of Python console) the following message: "Part Initialization Error: Default constructed ServiceReference is not valid input to GetService()".
Running it in Debug mode revealed that this is the result of throwing the exception within the ModuleContext::GetService(const ServiceReferenceBase& reference) as a result of PythonService not being registered at the moment of call which in turn happens within the mitk::PythonActivator::Load() during the call to PythonService constructor and BEFORE the PythonService is actually get registered.
Further digging in MITK forum archives, I came along the thread [mitk-users] Can't run Python plugin initiated by Matt Clarkson describing exactly the same problem and dated back to 2016. During the discussion, Miklos Espak provided the explanation for this phenomenon (bug in PythonQT related to static variables initialization) and outlined 3 ways to fix the problem, second of them being moving all PythonQT initialization related code from the static initialization.
Using his second suggestion I was able to successfully implement the fix allowing theplugin to succesfully load and run (including SimpleITK import, images drag and drop, simple processing etc).
My environment:
Windows 7 64bit ; VS 2017 Professional, Qt 5.12.3, Python 3.5.2 (Anaconda 4.2.0 bundle)
Short technical description of the problem:
The reason for the crash lies in the fact that the first attempt to use the mitk::PythonService happens within the mitk::PythonService() constructor (within mitk::PythonActivator::Load() method) as part of Python static initialization and BEFORE the service gets registed thorugh the m_PythonServiceRegistration = context->RegisterService<mitk::IPythonService>(m_PythonService.GetPointer(), _PythonServiceProps); call within the same Load method
Short technical description of the fix:
The idea of the fix is to defer the first query for the PythonService until the service is register by moving all python initialization related the mitk::PythonService() constructor functionality into new separate Initialize() method (also defining it within the IPythonService abstrct class) and calling this Initialize() method within the mitk:: QmitkPythonVariableStackTableModel() constructor.
Debugging the modified code has shown that now the first PythonService query indeed happens after it was actually registered which resolved the problem.
Please let me know if you need the corresponding diff file