# ModuleWizard.py crash on png file

**URL:** <https://discourse.slicer.org/t/modulewizard-py-crash-on-png-file/801>\
**Category:** Development\
**Created:** [August 1, 2017, 3:23pm UTC](https://discourse.slicer.org/t/modulewizard-py-crash-on-png-file/801 "2017-08-01T15:23:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JK\_Kim](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@JK\_Kim](https://discourse.slicer.org/u/JK_Kim)\
**Post date:** [August 1, 2017, 3:23pm UTC](https://discourse.slicer.org/t/modulewizard-py-crash-on-png-file/801/1 "2017-08-01T15:23:26Z")

</div>

1. Following on the HelloCLI tutorial…

2. Ran the `ModuleWizard.py` as follows…

```auto
/Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/CLIExtensionTemplate --target ../My_Module 
My_Module

```

1. Then, it crashes with the following error message… It seems like the script cannot handle .png file properly…

```auto
creating G:/Libs/slicer/My_Module/My_Module\My_Module.png
Traceback (most recent call last):
  File "g:\Libs\slicer\Slicer\Utilities\Scripts\ModuleWizard.py", line 121, in <module>
    main(sys.argv[1:])
  File "g:\Libs\slicer\Slicer\Utilities\Scripts\ModuleWizard.py", line 115, in main
    copyAndReplace(file, template, target, templateKey, moduleName)
  File "g:\Libs\slicer\Slicer\Utilities\Scripts\ModuleWizard.py", line 38, in copyAndReplace
    contents = fp.read()
  File "C:\Python36\lib\encodings\cp1252.py", 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>

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 1, 2017, 3:53pm UTC](https://discourse.slicer.org/t/modulewizard-py-crash-on-png-file/801/2 "2017-08-01T15:53:40Z")

</div>

Hi -

Thanks for reporting.

To confirm, you were using this tutorial?  
[https://www.slicer.org/wiki/Documentation/4.6/Training#HelloCLI](https://www.slicer.org/wiki/Documentation/4.6/Training#HelloCLI)

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.

[https://www.slicer.org/wiki/Documentation/4.6/Training#Developing\_and\_Contributing\_Extensions\_for\_3D\_Slicer](https://www.slicer.org/wiki/Documentation/4.6/Training#Developing_and_Contributing_Extensions_for_3D_Slicer)

HTH,  
Steve

---

<div class="post-metadata">

**Author:** ![JK\_Kim](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@JK\_Kim](https://discourse.slicer.org/u/JK_Kim)\
**Post date:** [August 2, 2017, 12:41am UTC](https://discourse.slicer.org/t/modulewizard-py-crash-on-png-file/801/3 "2017-08-02T00:41:23Z")

</div>

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,  
Jinkoo

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 2, 2017, 1:07pm UTC](https://discourse.slicer.org/t/modulewizard-py-crash-on-png-file/801/4 "2017-08-02T13:07:12Z")

</div>

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