Working on Ubuntu 16.04, python 2.7.12, I have this code (codec.py):
#!usr/bin/env python
# -*- coding: utf-8 -*-
import codecs
text = u'pi: \u03c0'
print text
Start program with: python codec.py work fine, and display:
pi: π
After compile this code with pyinstaller 3.3 I try to execute program with ./codec, but receive this error:
Traceback (most recent call last):
File "codec.py", line 7, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03c0' in position 4: ordinal not in range(128)
[6816] Failed to execute script codec
I have no solution for that issue. Have you ?
Solution was to modify line 7:
print text.encode("utf-8")
After compile with pyinstaller, program work fine, without error.