UnicodeError when running Python script via macOS LaunchAgent
If you are getting UnicodeErrors when reading/manipulating files using a Python script launched by a LaunchAgent or crontab, the problem might lie in the “current locale encoding”. Sample script Let’s assume you have the following code in a script set up to be launched by a LaunchAgent (also see my article on LaunchAgents): with open(some_path_to_file) as f: f.read() Let’s also assume that some_path_to_file points to a txt file containing some emojis (hey, why not? 😎) or some other unicode characters. ...