when I try to snap my application, which uses pythons gettext library for localization, the resulting snap exits with: python UnicodeEncodeError: 'ascii' codec can't encode characters in position 79-80: ordinal not in range(128)
The application does run fine if not run from a snap and as far as I can see, this kind of error usually comes when the system encoding isn’t correct. Does snap packages don’t use utf-8 as default encoding?
Also I’ve tried adding export LOCPATH=${SNAP}/localedir to the launcher script in case there’s something wrong with the paths, but that haven’t changed anything.
Whatever python script you are calling, is that through something setup through setup.py or something you manually crafted and added through a different part. If it is the latter, check the shebang and make sure it is using the correct one.
The addition of LC_ALL does fix my problem too. Thanks for that.
As for the other questions brought up, I’m using a custom plugin which inherits the python plugin and extends/changes it a bit. The script that causes the error is from the executable build with setup.py
Hi @sergiusens – This cost me probably 30m when I was packaging a couple simple python tools (this error of course leads you to think you messed something up in your string encoding/decoding) and I was wondering if it could get some more attention or even a workaround put in place inside snapcraft? It’s reported in bug:
I made this reproduction github in case anyone wanted to shortcut the problem.