Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

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

avatar
New Member

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

avatar
New Member

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')

View solution in original post

2 REPLIES 2

avatar
New Member

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')

avatar
New Member

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.