启动python,有些错误,如下。
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.interactivehook
Traceback (most recent call last):
File "D:Anaconda3libsite.py", line 440, in register_readline
readline.read_history_file(history)
File "D:Anaconda3libsite-packagespyreadline
lmain.py", line 165, in read_history_file
self.mode._history.read_history_file(filename)
File "D:Anaconda3libsite-packagespyreadlinelineeditorhistory.py", line 82, in read_history_file
for line in open(filename, 'r'):
UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 170: illegal multibyte sequence
实际上不影响使用,不过觉得不爽,网上由些解答是删除pyreadline。实际问题是读某个文件,其中包含了gbk编码,也就是中文,这里没办法解析。可能是pyreadline支持不够好,所以产生这个问题。
进一步查找,我这里的问题是开始时读pythonhistory文件,在c:userusername下,这个文件中包含了中文,你只要删除这个历史文件就好了。大部分情况是你的程序目录包含中文的原因。