Windows 上的命令行启动时出现 Anaconda unicode 错误 [英] Anaconda unicode error on command line startup on Windows

查看:44
本文介绍了Windows 上的命令行启动时出现 Anaconda unicode 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I got this error when running python from command line on Windows 10:

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 什么也没做.我在中文网站此处上发现了一个非常相似的问题,但该解决方案无济于事.

I have not changed anything about my python environment, I was just running some scripts that I've been working on for the last week. I honestly have no idea where this could be coming from; it seems to be an issue when python reads in its history. Updating python and conda did nothing. I found a very similar issue on a Chinese site here but the solution is unhelpful.

目前,我在继续运行 python 或我的脚本时找不到任何问题,但我不希望它回来咬我.任何帮助表示赞赏!

At the moment, I cannot find any issues when continuing to run python or my scripts, but I don't want this to come back and bite me. Any help is appreciated!

推荐答案

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

As user metatoaster commented, the python history file contains bytes that cannot be decoded by your system's default encoding and may be deleted. If the file contains commands that you want to keep or review you can take a backup first and try reviewing its contents in a text editor.

您的历史文件包含无法解码的字符.删除历史文件(POSIX:~/.python_history,在 Windows 上它可能是 %userprofile%/.python_history)并查看问题是否消失.

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.

这篇关于Windows 上的命令行启动时出现 Anaconda unicode 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆