Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 903
Shashank Raj Avatar asked Oct 29 '25 03:10

Shashank Raj


1 Answers

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

like image 183
Shashank Raj Avatar answered Oct 30 '25 16:10

Shashank Raj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!