Failed calling sys.__interactivehook__ 错误的解决

启动python,有些错误,如下。

PS D:\........> python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 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:\Programs\Python37\lib\site.py", line 439, in register_readline
    readline.read_history_file(history)
  File "C:\Programs\Python37\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\Programs\Python37\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 0xae in position 185: illegal multibyte sequence

实际上不影响使用,不过觉得不爽,网上由些解答是删除pyreadline。实际问题是读某个文件,其中包含了gbk编码,也就是中文,这里没办法解析。可能是pyreadline支持不够好,所以产生这个问题。

进一步查找,我这里的问题是开始时读pythonhistory文件,在c:\user\username\下,这个文件中包含了中文,你只要删除这个历史文件就好了。大部分情况是你的程序目录包含中文的原因。

你可能感兴趣的:(python,python,算法)