unicodeit icon indicating copy to clipboard operation
unicodeit copied to clipboard

Mac automator error message

Open wuziqiqiqi opened this issue 5 years ago • 5 comments

UnicodeEncodeError: 'ascii' codec can't encode character '\u03b1' in position 0: ordinal not in range(128)”

wuziqiqiqi avatar Sep 18 '20 17:09 wuziqiqiqi

I haven't seen this error before. Are you using Python2? This is for Python 3 only.

svenkreiss avatar Jan 09 '21 21:01 svenkreiss

I ran into the same issue. I solved it by setting the PYTHONIOENCODING environment variable in the automator script, so it becomes:

PYTHONIOENCODING=UTF-8 /usr/local/bin/python3 -m unicodeit.cli $1

peterparity avatar Feb 01 '21 20:02 peterparity

Thanks! This is very helpful @peterparity . I assumed this was a given on all Macs. Do you know what you normal io-encoding is? It seems it depends on the terminal. Do you mind sharing the output of:

python3 -c "import sys; print(sys.stdout.encoding)"

Mine says utf-8 already.

svenkreiss avatar Feb 02 '21 08:02 svenkreiss

I think the problem for me is that I'm actually using a separately installed python 3 (using anaconda). When I run in the terminal I get UTF-8 for both the anaconda python and the system python. However, when I run inside of Mac automator, the system python gives utf-8 but the anaconda python gives US-ASCII. I'm not sure why this is the case, but it explains why I'm seeing this error.

peterparity avatar Feb 02 '21 16:02 peterparity

Very helpful. Thanks! I'll try to put some clarification in the readme.

svenkreiss avatar Feb 03 '21 08:02 svenkreiss