Error desc:
This type of error comes when some special character is not in range of selected encoding type.
Solution :
Find the default encoding type of python.
python -c 'import sys; print(sys.getdefaultencoding())'
o/p : ascii
We need to change the encoding type and try with different type of encoding. e.g.
latin-1
utf-8
utf-16-be
Create a file sitecustomize.py under this location : /usr/lib/python2.7/site-packages/sitecustomize.py
echo "import sys; sys.setdefaultencoding('latin-1')" > sitecustomize.py
Compile the python script and check the encoding type is changed by below command.
python -m py_compile sitecustomize.py
PYTHONPATH=".:$PYTHONPATH" python -c 'import sys; print(sys.getdefaultencoding())'
o/p : latin-1
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0:
ordinal not in range(128)
This type of error comes when some special character is not in range of selected encoding type.
Solution :
Find the default encoding type of python.
python -c 'import sys; print(sys.getdefaultencoding())'
o/p : ascii
We need to change the encoding type and try with different type of encoding. e.g.
latin-1
utf-8
utf-16-be
Create a file sitecustomize.py under this location : /usr/lib/python2.7/site-packages/sitecustomize.py
echo "import sys; sys.setdefaultencoding('latin-1')" > sitecustomize.py
Compile the python script and check the encoding type is changed by below command.
python -m py_compile sitecustomize.py
PYTHONPATH=".:$PYTHONPATH" python -c 'import sys; print(sys.getdefaultencoding())'
o/p : latin-1
No comments:
Post a Comment
Thank You for your valuable comment