crash on png file

  1. Following on the HelloCLI tutorial…

  2. Ran the as follows…

/Utilities/Scripts/ --template ./Extensions/Testing/CLIExtensionTemplate --target ../My_Module 
  1. Then, it crashes with the following error message… It seems like the script cannot handle .png file properly…
creating G:/Libs/slicer/My_Module/My_Module\My_Module.png
Traceback (most recent call last):
  File "g:\Libs\slicer\Slicer\Utilities\Scripts\", line 121, in <module>
  File "g:\Libs\slicer\Slicer\Utilities\Scripts\", line 115, in main
    copyAndReplace(file, template, target, templateKey, moduleName)
  File "g:\Libs\slicer\Slicer\Utilities\Scripts\", line 38, in copyAndReplace
    contents =
  File "C:\Python36\lib\encodings\", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 154: character maps to <undefined>

Hi -

Thanks for reporting.

To confirm, you were using this tutorial?

It may be that the ModuleWizard script only works with python 2.7 (looks like you are using 3.6). Maybe try that and let us know?

Also the ExtensionWizard is probably a better way now. If you look at this “Developing and Contributing Extensions for 3D Slicer” tutorial you can see how it works. The only difference is that you pick ‘cli’ instead of ‘scripted’ when adding the module to your extension.


1 Like

Yes, I was using the HelloCLI tutorial of the link.

Just now, I removed python36 and installed python27. The ModuleWizard
script finished without any error, but the png file got corrupted and I
could not open it. I assume…, not 100% sure… me, a python newbie… it
is because the file was open as text file, modified, and saved as text
file… If my assumption is right…, I guess the same is true for all
other binary files (the image files in the Data sub-folder).

Thanks for the link regarding ExtentionWizard. I’ll try it.

Best regards,

The included .png file is just a placeholder. Replace it with your own icon.