[PYTHON] yum throws "UnicodeDecodeError:'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range (128)" error

Environmental information

RedHat Enterprise Linux 7.1

Event

bash


[[email protected] yum.repos.d]# yum search zsh
Loaded plugin:langpacks, product-id, subscription-manager
'ascii' codec can't decode byte 0xe3 in position 0: ordinal not in range(128)
============================================ N/S matched: zsh ============================================
zsh-html.x86_64 : Zsh shell manual in html format
zsh.x86_64 : Powerful interactive shell

  Name and summary matches only, use "search all" for everything.

Something came out

bash


'ascii' codec can't decode byte 0xe3 in position 0: ordinal not in range(128) 

How to deal with the official website

https://access.redhat.com/solutions/284023

Cause

Countermeasures

If you can't do 1, do 2

1. Erase yumdb

bash


mv /var/lib/yum/yumdb/ /tmp
yumdb sync

2. Change python default encoding

Apparently yum is like a python script.

python


vi /usr/lib/python2.7/site-packages/sitecustomize.py

import sys
sys.setdefaultencoding("utf-8")

Conclusion

RedHat is bad because it wasn't CentOS.

Recommended Posts

yum throws "UnicodeDecodeError:'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range (128)" error
UnicodeDecodeError:'ascii' codec can't decode byte 0xa4 in position 0: ordinal not in range (128)
'Ascii' codec can't encode characters in position xx-xx: ordinal not in range (128) when calling PHP → Python
When codec can't decode byte appears in python
Mecab --UnicodeDecodeError:'utf8' codec can't decode byte
UnicodeDecodeError:'utf-8' codec ca n’t decode byte 0x91 in position 1: invalid start byte
SyntaxError: (unicode error)'unicodeescape' codec can't decode bytes in position 2-3: truncated \ UXXXXXXXX escape
UnicodeDecodeError: What to do when'shift_jis' codec can't decode byte