시행착오의 흔적들/디버깅 노트
UnicodeDecodeError: 'cp949' codec can't decode byte 0xeb in position 1251: illegal multibyte sequence
HyunJung_Jo
2021. 9. 2. 10:38
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:\Users\coco7\anaconda3\lib\site.py", line 440, in register_readline
readline.read_history_file(history)
File "C:\Users\coco7\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
self.mode._history.read_history_file(filename)
File "C:\Users\coco7\anaconda3\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
for line in open(filename, 'r'):
UnicodeDecodeError: 'cp949' codec can't decode byte 0xeb in position 1251: illegal multibyte sequence
무슨 이유에선지 아나콘다 패키지를 깔다보면 터미널에서 파이썬을 실행할 때 인코딩 오류가 한번 씩 난다. 이럴때 오류 메시지에 나온 history.py에 메모장으로 들어가서 인코딩을 utf-8으로 고쳐주면 된다.
for line in open(filename, 'r'):
for line in open(filename, 'r',encoding='UTF-8'):