• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

anaconda spyder出错解决方法

相关文章 搞java代码 3年前 (2022-05-21) 86次浏览 已收录 0个评论

anaconda spyder出错解决方法

anaconda spyder出错解决:(推荐:anaconda使用教程)

写Python程序时突然遇到报错:

This command failed to be executed because an <a href="https://www.gaodaima.com/tag/error" title="查看更多关于error的文章" target="_blank">error</a> occurred while trying to get the file code from Spyder's editor. The error was:


An exception has occurred, use %tb to see the full traceback.

UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 582: illegal multibyte sequence

UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 611: illegal multibyte sequence

In [2]: %tb
Traceback (most recent call last):

  File "C:UserspeterAnaconda3libsite-packages<a href="https://www.gaodaima.com/tag/spyder" title="查看更多关于spyder的文章" target="_blank">spyder</a>_kernelscustomizespydercustomize.py", line 401, in get_file_code
    return f.read()

UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 582: illegal multibyte sequence

www#gaodaima.com来源gao.dai.ma.com搞@代*码网搞代码

先尝试重启程序,也许报错就解决了。

解决方法是根据报错,修改文件C:UserspeterAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py为:

def get_file_code(filename):
    """Retrive the content of a file."""
    # Get code from spyder
    try:
        file_code = frontend_request().get_file_code(filename)
    except (CommError, TimeoutError):
        file_code = None
    if file_code is None:
        with open(filename, 'r',encoding='utf-8') as f:#增加 ,encoding='utf-8'
            return f.read()
    return file_code

如果不重启程序,会报错:

[autoreload of spydercustomize failed: Traceback (most recent call last):
  File "C:UserspeterAnaconda3libsite-packagesIPythonextensionsautoreload.py", line 245, in check
    superreload(m, reload, self.old_objects)
  File "C:UserspeterAnaconda3libsite-packagesIPythonextensionsautoreload.py", line 394, in superreload
    module = reload(module)
  File "C:UserspeterAnaconda3libimp.py", line 314, in reload
    return importlib.reload(module)
  File "C:UserspeterAnaconda3libimportlib\__init__.py", line 168, in reload
    raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name)
ModuleNotFoundError: spec not found for the module 'spydercustomize'
]
This command failed to be executed because an error occurred while trying to get the file code from Spyder's editor. The error was:


An exception has occurred, use %tb to see the full traceback.

UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 582: illegal multibyte sequence

更多python知识请关注python教程。

来源:搞代码网:原文地址:https://www.gaodaima.com


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:anaconda spyder出错解决方法

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址