Search code examples
python-3.xcronpython-unicodecron-task

Throws UnicodeEncodeError when python script run via cron


My python script run fine when ran manually but whenever run from cron job it throws UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in position 0: ordinal not in range(128)

myfile.py:

print(u"\u2122")

I am on macos high sierra and python version is 3.6.0


Solution

  • Fixed it by putting on top of crontab:

    LC_ALL="en_US.UTF-8"