简体   繁体   中英

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 2310: character maps to <undefined>

I have recently been working on Python and have started to face this issue even when I just start the Python Interactive terminal using the command prompt. I referred this question but I have not been executing any python code as suggested in that question; but am just entering the python shell using python command inside a fresh command prompt (PS: I am using Windows 10)

The error I seem to face is:

C:\Users\>python
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "D:\anaconda3\lib\site.py", line 440, in register_readline
    readline.read_history_file(history)
  File "D:\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "D:\anaconda3\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
  File "D:\anaconda3\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 2310: character maps to <undefined>

>>>

I don't find any line where I can add the "utf8" in any suggested lines.

Try deleting .python_history file which would be under C:\Users\<user-name>\ . There seem to be more gibberish in your history file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM