View Issue Details

IDProjectCategoryView StatusLast Update
0003894Slicer4Core: Scripting (Wrapping, Python)public2016-01-26 12:19
Reporterpinter Assigned Topinter  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version 
Target VersionSlicer 4.6.0Fixed in VersionSlicer 4.5.0-1 
Summary0003894: Python wrapped classes not loaded when starting from Visual Studio for debugging
Description

This error message shows up in the python interactor if starting Slicer without the launcher (from Visual Studio or Xcode):

Traceback (most recent call last):
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/DataProbe.py", line 65, in addView
self.infoWidget = DataProbeInfoWidget(parent,type='small')
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/DataProbe.py", line 90, in init
self.createSmall()
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/DataProbe.py", line 284, in createSmall
self.sliceAnnoations = DataProbeLib.SliceAnnotations()
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules\DataProbeLib\SliceViewAnnotations.py", line 126, in init
self.updateSliceViewFromGUI()
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules\DataProbeLib\SliceViewAnnotations.py", line 402, in updateSliceViewFromGUI
self.createCornerAnnotations()
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules\DataProbeLib\SliceViewAnnotations.py", line 493, in createCornerAnnotations
self.createActors(sliceViewName)
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules\DataProbeLib\SliceViewAnnotations.py", line 524, in createActors
self.colorScalarBars[sliceViewName] = self.createColorScalarBar(sliceViewName)
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules\DataProbeLib\SliceViewAnnotations.py", line 577, in createColorScalarBar
scalarBar = slicer.vtkPVScalarBarActor()
AttributeError: 'module' object has no attribute 'vtkPVScalarBarActor'

DICOM loading is not possible afterwards, because the python-wrapped module logic classes are not loaded due to a wrong sys.path (qt-loadable-modules folder is in the list, but the qt-loadable-modules/Debug is not)

Additional Information

Discussion thread:
http://slicer-devel.65872.n3.nabble.com/Python-error-related-to-slice-view-annotations-with-4-4-td4032798.html

TagsNo tags attached.

Relationships

related to 0003876 closedjcfr All python modules fail after uninstalling an extension 

Activities

pinter

pinter

2014-11-14 06:06

developer   ~0012697

I'm leaning towards thinking that this problem is not specific to SliceViewAnnotations.
If the annotations are disabled, then I still get an error if trying to load scalar volume from DICOM:

Traceback (most recent call last):
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules\DICOMLib\DICOMWidgets.py", line 516, in loadCheckedLoadables
if not plugin.load(loadable):
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/DICOMScalarVolumePlugin.py", line 304, in load
volumeNode = self.loadFilesWithArchetype(loadable.files, loadable.name)
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/DICOMScalarVolumePlugin.py", line 299, in loadFilesWithArchetype
return(volumesLogic.AddArchetypeScalarVolume(files[0],name,0,fileList))
AttributeError: AddArchetypeScalarVolume

Digging deeper, it seems that many python modules are out of reach. For example if I want to explicitly import volumes logic, then I get this:

import vtkSlicerVolumesModuleLogic
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:/d/S4D/Slicer-build/lib/Slicer-4.4/qt-loadable-modules/Python\vtkSlicerVolumesModuleLogic.py", line 5, in <module>
from vtkSlicerVolumesModuleLogicPython import *
ImportError: No module named vtkSlicerVolumesModuleLogicPython

Same happens with logic and MRML for other loadable modules too. The reason of this is beyond my knowledge.

pinter

pinter

2014-11-24 14:07

developer   ~0012726

  1. sys.path did not include ...loadable-modules/Debug, but only the one without Debug
  2. Specified working directory in VS project settings, problem solved
  3. Removed working directory (i.e. revert to state where it failed), still worked!

Suspicion: wrong SlicerLauncherSettings.ini file is found, or wrong launcher is executed.
Next time we have this issue: I use a batch file that starts VS with environment, contains '.\S4D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash'. This uses relative path and may result in wrong automatic finding of ini or other files. Next time try cd S4D/Slicer-build then Slicer.exe instead of .\S4D\Slicer-build\Slicer.exe

jcfr

jcfr

2014-11-25 09:59

administrator   ~0012727

It may be worth adding print statement and/or break point to qSlicerCoreApplicationPrivate::discoverSlicerHomeDirectory()

pinter

pinter

2014-12-02 06:04

developer   ~0012744

The issue came back with a clean build, and cannot fix it with the steps I did before.

pinter

pinter

2014-12-02 06:10

developer   ~0012745

qSlicerCoreApplicationPrivate::discoverSlicerHomeDirectory() returns the proper Slicer-build directory

jcfr

jcfr

2014-12-02 06:14

administrator   ~0012746

Can your start Slicer outside of Visual Studio using the launcher ?

pinter

pinter

2014-12-02 06:20

developer   ~0012747

Yes, and it works as expected. Somehow the sys.path is different if I start it from VS (launching the Slicer-App project after starting VS with the launcher). The difference that causes the problems is that Slicer-build/lib/Slicer-4.4/qt-loadable-modules/Debug is missing (or Release, because it doesn't work with release either)

pinter

pinter

2014-12-02 06:23

developer   ~0012748

Also there is a very strange entry in the faulty sys.path:
'C:\d\S4R\Slicer-build\bin\Release:C:\d\S4R\Slicer-build\bin\Python:C:\d\S4R\Slicer-build\lib\Slicer-4.4:C:\d\S4R\Slicer-build\lib\Slicer-4.4\qt-loadable-modules:C:\d\S4R\Slicer-build\lib\Slicer-4.4\qt-loadable-modules\Python:C:\d\S4R\Slicer-build\lib\Slicer-4.4\qt-scripted-modules:C:\d\S4R\VTKv6-build\bin\Release\:C:\d\S4R\VTKv6-build\Wrapping\Python:C:\d\S4R\CTK-build\CTK-build\bin\Release\:C:\d\S4R\CTK-build\CTK-build\bin\Python'

Apparently it's constructed in a wrong way, there is no single quota and comma, but a colon. Strange...

pinter

pinter

2014-12-02 10:44

developer   ~0012753

Sorry, I commented to the wrong ticket. I'm removing it and reopening this one.

pinter

pinter

2014-12-02 11:54

developer   ~0012761

The problem is that PYTHONPATH is made empty by the function qSlicerExtensionsManagerModelPrivate::removeExtensionPathFromLauncherSettings at line 565. This should not be done, as empty is never good. Also I'm not sure this variable should be saved in the Slicer-NNNNN.ini, but there might be some legitim reason.

Second, the "strange" invalid merged one-line path comes from qSlicerCoreApplicationPrivate::setPythonEnvironmentVariables(), where this variable is constructed at line 527, and it is done linux-style. I understand that many core developers use linux, but most users use Windows, so that platform should be considered at all times.

All this is done because Slicer "thinks" I removed an extension (due to my own ini file magic that I do to make my life easier by not manually adding all the module paths when changing Slicer revision that happens awfully often), this is why I set it related to 0003876, which is basically the same issue.

Jc, can you please comment on these? Thanks!

pinter

pinter

2014-12-02 12:07

developer   ~0012762

Last edited: 2014-12-03 06:30

Fixed the "extension removed" issue (just locally so that it doesn't occur, not the root cause), but the sys.path is still corrupt, so not the same issue as 0003876, still related. Investigating why the path is wrong

pinter

pinter

2015-04-23 07:04

developer   ~0013017

This problem has not occurred in the last few months. I'm pretty sure it was due to the extension removal problem (and maybe some old windows disease too).

pinter

pinter

2016-01-26 12:19

developer   ~0013752

The problem seems to be gone now, closing the issue

Issue History

Date Modified Username Field Change
2014-11-13 12:58 pinter New Issue
2014-11-13 13:27 fedorov Status new => assigned
2014-11-13 13:27 fedorov Assigned To => mehrtash
2014-11-14 06:06 pinter Note Added: 0012697
2014-11-24 14:07 pinter Note Added: 0012726
2014-11-24 14:07 pinter Status assigned => closed
2014-11-24 14:07 pinter Resolution open => no change required
2014-11-25 09:59 jcfr Note Added: 0012727
2014-12-02 06:04 pinter Assigned To mehrtash =>
2014-12-02 06:04 pinter Note Added: 0012744
2014-12-02 06:04 pinter Status closed => feedback
2014-12-02 06:04 pinter Resolution no change required => reopened
2014-12-02 06:06 pinter Category Module DataProbe => Core: Scripting (Wrapping, Python)
2014-12-02 06:06 pinter Summary Python error messages related to SliceViewAnnotations when starting without launcher => Python wrapped classes not loaded when starting from Visual Studio for debugging
2014-12-02 06:06 pinter Description Updated
2014-12-02 06:10 pinter Note Added: 0012745
2014-12-02 06:14 jcfr Note Added: 0012746
2014-12-02 06:20 pinter Note Added: 0012747
2014-12-02 06:23 pinter Note Added: 0012748
2014-12-02 09:25 pinter Status feedback => resolved
2014-12-02 09:25 pinter Fixed in Version => Slicer 4.4.1
2014-12-02 09:25 pinter Resolution reopened => fixed
2014-12-02 09:25 pinter Assigned To => pinter
2014-12-02 10:29 jcfr Status resolved => closed
2014-12-02 10:29 jcfr Target Version => Slicer 4.4.1
2014-12-02 10:44 pinter Note Added: 0012753
2014-12-02 10:45 pinter Status closed => feedback
2014-12-02 10:45 pinter Resolution fixed => reopened
2014-12-02 11:50 pinter Relationship added related to 0003876
2014-12-02 11:54 pinter Note Added: 0012761
2014-12-02 12:07 pinter Note Added: 0012762
2014-12-03 06:30 pinter Note Edited: 0012762
2015-04-23 07:04 pinter Note Added: 0013017
2015-09-09 08:29 jcfr Fixed in Version Slicer 4.4.1 => Slicer 4.5.0-1
2015-09-09 08:29 jcfr Target Version Slicer 4.4.1 => Slicer 4.5.0-1
2015-11-02 11:27 jcfr Target Version Slicer 4.5.0-1 => Slicer 4.6.0
2016-01-26 12:19 pinter Note Added: 0013752
2016-01-26 12:19 pinter Status feedback => assigned
2016-01-26 12:19 pinter Status assigned => closed
2016-01-26 12:19 pinter Resolution reopened => fixed