Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 191: ordinal not in range(128)

Solved Go to solution

Install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 191: ordinal not in range(128)

New Contributor

Env: Ubuntu 14.04.1 HDP 2.4

Trying to install nifi with https://github.com/abajwa-hw/ambari-nifi-service but I am ending up with

	Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.4/services/NIFI/package/scripts/master.py", line 201, in <module>
    Master().execute(
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 219, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.4/services/NIFI/package/scripts/master.py", line 109, in install
    self.configure(env, True)
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.4/services/NIFI/package/scripts/master.py", line 145, in configure
    Execute(format("cd {params.conf_dir}; mv flow.xml.gz flow_$(date +%d-%m-%Y).xml.gz ;"), user=params.nifi_user, ignore_failures=True)
  File "/usr/lib/python2.6/site-packages/resource_management/core/base.py", line 154, in __init__
    self.env.run()
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 163, in run
    Logger.info("Skipping failure of %s due to ignore_failures. Failure reason: %s" % (resource, str(ex)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 191: ordinal not in range(128)

More info here

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 191: ordinal not in range(128)

New Contributor

Fixed with this code

+# encoding=utf8
 +
  import sys, os, pwd, grp, signal, time, glob  import sys, os, pwd, grp, signal, time, glob
  from resource_management import *  from resource_management import *
  from subprocess import call  from subprocess import call

 +reload(sys)
 +sys.setdefaultencoding('utf8')
2 REPLIES 2

Re: Install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 191: ordinal not in range(128)

New Contributor

Fixed with this code

+# encoding=utf8
 +
  import sys, os, pwd, grp, signal, time, glob  import sys, os, pwd, grp, signal, time, glob
  from resource_management import *  from resource_management import *
  from subprocess import call  from subprocess import call

 +reload(sys)
 +sys.setdefaultencoding('utf8')

Re: Install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 191: ordinal not in range(128)

New Contributor

Python's default encoding is ASCII which throws UnicodeDecodeError when trying to decode a stream/array of bytes to Unicode. Setting the default encoding to UTF-8 will fix the conversion from bytes to UTF-8 encoded string.