gpt4 book ai didi

python - 在 Windows 上命令行启动时出现 Anaconda unicode 错误

转载 作者:太空狗 更新时间:2023-10-30 01:25:05 36 4
gpt4 key购买 nike

在 Windows 10 上从命令行运行 python 时出现此错误:

C:\Users\windows> python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 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:\ProgramData\Anaconda3\lib\site.py", line 410, 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'):
File "C:\ProgramData\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 991: character maps to <undefined>

我没有对我的 python 环境进行任何更改,我只是运行了上周我一直在处理的一些脚本。老实说,我不知道这是从哪里来的;当 python 读取其历史记录时,这似乎是一个问题。更新 python 和 conda 什么也没做。我在中文网站上发现了一个非常相似的问题here但解决方案无济于事。

目前,我在继续运行 python 或我的脚本时找不到任何问题,但我不希望它回来咬我。感谢您的帮助!

最佳答案

作为用户 metatoaster commented ,python 历史文件包含无法通过系统默认编码解码的字节,可能会被删除。如果文件包含您想要保留或查看的命令,您可以先备份并尝试在文本编辑器中查看其内容。

You have a history file that contain characters that cannot be decoded. Remove the history file (POSIX: ~/.python_history, on Windows it might be %userprofile%/.python_history) and see if that problem goes away.

关于python - 在 Windows 上命令行启动时出现 Anaconda unicode 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52049887/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com