UnicodeEncodeError only when running as a cron job [duplicate]
Nah, you can have it simpler. Just define PYTHONIOENCODING before executing this script. Like this:
PATH=<your path>MAILTO=someone@somewherePYTHONIOENCODING=utf8* * * * * /run/your/script
Aside: This is a common problem; as such this is probably a duplicate question.
The default encoding on 2.7 is ascii
.
You need to provide an encoding for your program's output.
A common encoding to use is 'utf8'.
So you'd do instead:
print title.encode('utf8')
Here's one way to check the default encoding:
import syssys.getdefaultencoding()# -> 'ascii'