%运行另一个笔记本时Jupyter中的编码错误 [英] Encoding error in Jupyter when %run another notebook

查看:130
本文介绍了%运行另一个笔记本时Jupyter中的编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jupyter笔记本中使用西里尔符号.
在笔记本1号中,我运行笔记本2号.

I use cyrillic symbols in my Jupyter notebooks.
In NoteBook №1 I run NoteBook №2.

%run ./NB2.ipynb

在笔记本№2中,我写了一些txt文件.

In NoteBook №2 I write in some txt file.

TestText = open('C:\\TRASH\\test_text.txt', 'w')
a = 'Иридий' #Iridium
TestText.write(a+'\n')
TestText.close()

当NB1启动时,我得到UnicodeDecodeError.

And when NB1 starts I get UnicodeDecodeError.

...can't decode byte 0x98

有完整的输出: http://collabedit.com/tcev6

简而言之,Nbformat库调用core.reads,它依次以win-1251编码读取NB2.这就是为什么第一个И"是问题所在.

Briefly, Nbformat library call core.reads which, in its turn, read NB2 in win-1251 encoding. That's why first 'И' is the problem.

是否有选择阅读第二本笔记本的编码的常规方法?

Is there a regular way to choose the encoding for reading second notebook?

推荐答案

https://github .com/ipython/ipython/pull/10558 该错误已于2017年5月13日修复并合并.

https://github.com/ipython/ipython/pull/10558 This bug was fixed and merged at 13 May 2017.

这篇关于%运行另一个笔记本时Jupyter中的编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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