Warning information about “Gyroguide“

Hi everyone,
In module “Gyroguide”, after the markers setting, click “calculate”, the warning information showed as below:Traceback (most recent call last):
File “/Applications/Slicer.app/Contents/Extensions-32448/GyroGuide/lib/Slicer-5.6/qt-scripted-modules/GyroGuide.py”, line 367, in onCalculateButtonClicked
result = PuncturePlannerCalculator(markersFiducialsNode, targetFiducialNode, entryFiducialNode)
File “/Applications/Slicer.app/Contents/Extensions-32448/GyroGuide/lib/Slicer-5.6/qt-scripted-modules/GyroGuide.py”, line 577, in init
for j in xrange(n):
NameError: name ‘xrange’ is not defined
What the reason about this problem and how to fix the issue?
Best wishes,
Xie

Hi @doc-xie - xrange was available in older Slicer versions that used Python2, but it’s not in Python3, so it should be range instead. There’s some background on the transition here: Updating slicer to work with python 3

Thanks Steve Pieper,
I agree with you that the reason is the -xrange was not compatible with Python3. But I was confused with the transition. I want to know is there a easy way to solve the problem? The version of Python in my 3D Slicer is "3.9.10 (main, Apr 5 2024, 00:33:09) "
Best wishes,
Xie

Hi Xie, it is definitely a developer task to make the code python 3 compatible. The easiest way for a developer to do this would be to utilize the pre-commit framework with a hook to run pyupgrade. That will then automatically apply fixes to upgrade the code syntax to a specific python version such as 3.9 as used by latest Slicer.

See for example this specification of pyupgrade in a pre-commit configuration file.

Note that the GyroGuide extension hasn’t significantly been updated since 2015 which is a very long time. Do you know Luping Fang who appears to be the main developer of that extension?

Hi James Butler,
I do not know LP Fang, but I will try to contact with him about this issue. Hope this problem can be solved in no time.
Best wishes,
Xie