執行 python,突然出現 UnicodeDecodeError: ‘cp950‘ codec

在使用Python3.9.7和Anaconda环境中,遇到启动时的交互式hook失败问题,具体表现为尝试读取历史文件时,因'cp950'编码无法解码字节导致UnicodeDecodeError。解决方法是删除用户目录下的.python_history文件,从而消除编码错误并恢复正常运行。
摘要由CSDN通过智能技术生成

使用 pyinstaller 後,突然發現

Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.
Failed calling sys.interactivehook
Traceback (most recent call last):
File “C:\ProgramData\Anaconda3\lib\site.py”, line 449, in register_readline
readline.read_history_file(history)
File “C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\rlmain.py”, line 165, in read_history_file
self.mode._history.read_history_file(filename)
File “C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\lineeditor\history.py”, line 82, in read_history_file
for line in open(filename, ‘r’):
UnicodeDecodeError: ‘cp950’ codec can’t decode byte 0xb3 in position 3656: illegal multibyte sequence

解決辦法:
1.刪除使用者目錄下之
在这里插入图片描述
刪除這個 .python_history 檔案
這樣就OK了

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值