目录
背景
今天因为需要重装系统,所以将开发环境再来装了个遍。在装anaconda的时候一切正常,但是在cmd窗口运行python的时候报错了,但是小意思。
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:\software\anconda\install\lib\site.py", line 440, in register_readline
readline.read_history_file(history)
File "C:\software\anconda\install\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
self.mode._history.read_history_file(filename)
File "C:\software\anconda\install\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 0x8f in position 28: illegal multibyte sequence
>>>
解决
通过问题定位,是编码问题,快速找到对应的代码文件,进行问题解决
定位到82行,将代码:
for line in open(filename, 'r'):
改为:for line in open(filename, 'r',encoding='utf-8') 然后进行保存。
再次测试(搞定)