Error when starting Python in Windows

Error message

Start Python 3.6 in the windows command line environment and report the following error

C:\Users\gaozh>python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site.py", line 418, in register_readline
    readline.read_history_file(history)
  File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\Anaconda3\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 407: illegal multibyte sequence

terms of settlement

The way to solve this problem is to modify the corresponding code in line 82 of the file C: \ anaconda3 \ lib \ site packages \ pyreadline \ lineeditor \ history. Py , add the coding format as UTF-8 , and then restart python.

Reference articles

https://github.com/pyreadline/pyreadline/issues/38

Read More: