当我使用指定的参数执行this SageMathCell时,有时会正确执行,有时会出现以下错误:
ValueError Traceback (most recent call last)
<ipython-input-1-253427808e04> in <module>()
117 show(plot(t,title=heading,vertex_labels=False,layout='tree',figsize=Integer(4)))
118 else:
--> 119 print heading
120 L = successor(L)
121 else:
/home/sc_serv/sage/local/lib/python2.7/site-packages/ipykernel/iostream.py in write(self, string)
315
316 is_child = (not self._is_master_process())
--> 317 self._buffer.write(string)
318 if is_child:
319 # newlines imply flush in subprocesses
ValueError: I/O operation on closed file
该错误始终指向第119行,该行仅显示字符串。该行出现在多次执行的循环中,并且发生错误的特定迭代似乎是完全随机的。有时循环几乎结束,有时仅经过几次迭代便崩溃。更奇怪的是,如果我将print_images设置为true(这会使标题作为图形的一部分而不是简单的字符串打印),则永远不会发生该错误。到底是怎么回事?
最佳答案
原来,该问题已解决,但由于当前的ipykernel主版本为4.3.0dev,而最新版本为4.3.1,因此该问题再次出现。我已经调整了安装命令,无法再出现此问题-错误行现在已正确包装。感谢您的举报!
关于python - SageMathCell ValueError打印字符串时(有时),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37692165/