The call to subprocess.check_output returns a bytes instead of a str object if not called with universal_newlines=True which raises an exception further on due to mixing of bytes and str.