ranjian0 / Blender-PyCharm

Example setup for blender addon development in pycharm
58 stars 11 forks source link

Explicitly specifying the encoding to "utf-8". #3

Closed iwoplaza closed 2 years ago

iwoplaza commented 2 years ago

This fixes a crash of the script. Without explicitly stating the encoding, it raises a UnicodeEncodeError:

(...)
class FaceMaps:

class FieldSettings:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 1177, in <module>
    main() #just run it! Unconditional call makes it easier to debug Blender script in Eclipse,
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 1144, in main
    rna2predef(path_in_tmp)
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 1053, in rna2predef
    bpy2predef(BASEPATH,"Blender API main module")
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 1036, in bpy2predef
    rna_struct2predef(_IDENT, fw, cls)
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 917, in rna_struct2predef
    rna_property2predef(ident,fw,prop)
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 876, in rna_property2predef
    write_indented_lines(ident, fw, definition["docstring"], False)
  File "D:\Projects\Blender Addons\predef\pypredef_gen.py", line 172, in write_indented_lines
    fn(ident + l + "\n")
  File "D:\Programs\Blender 2.81\2.81\python\lib\encodings\cp1250.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\xb2' in position 37: character maps to <undefined>

Blender quit
ranjian0 commented 2 years ago

It's been a while since I used this workflow but I recommend to switch to https://pypi.org/project/fake-bpy-module-2.93/ for bpy definitions.

Just install in virtualenv with pip and use that for development.

iwoplaza commented 2 years ago

Thanks for the tip! Didn't know that existed, this GitHub repo is the first thing that popped up when I wanted to find PyCharm integration. Mind adding that switch recommendation at the beginning of the main README.md for future stumblers ❤️ ?

ranjian0 commented 2 years ago

yep, this is a very old workflow now. Will add the notice