Need to specify decoding to latex
Not sure why this was only catching NameError, as it also needs to catch ImportError