site-packages\pyreadline\lineeditor\history.py“, line 82, in read_history_file for line in open

目录

背景

解决

再次测试(搞定)


背景

今天因为需要重装系统,所以将开发环境再来装了个遍。在装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') 然后进行保存。

再次测试(搞定)

    

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值