打印不显示在ipython笔记本中 [英] Print not showing in ipython notebook

查看:105
本文介绍了打印不显示在ipython笔记本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ipython 笔记本( http:// ipython .org / notebook.html )做一个演示,看起来打印功能似乎不起作用:

I am using ipython notebook (http://ipython.org/notebook.html) to do a demo and it seems like the print function is not working:

为清楚起见,上面图片中的命令将被重写。

The commands in the above picture are rewritten here for clarity.

In [1]: 'hello world'
Out [1]: 'hello world'

In [2]: print 'hello world'

简而言之,没有打印输出来自 [2]

In short, there's no print output from the [2].

有谁知道这是否是一个已知错误?有没有人知道如何修复它?

Does anyone know whether it's a known bug? And does anyone know how to fix it?

推荐答案

当我的第一个代码单元格出现时,我遇到了类似的打印问题:

I had a similar printing problem when my first code cell was:

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

然后我评论了第二行和第三行:

Then I've commented the second and third lines like this:

import sys
#reload(sys)
#sys.setdefaultencoding("utf-8")

重置内核并重新运行程序,现在我的print语句正常工作。

Reset the kernel and re-ran the program and now my print statements are working properly.

稍后在,我发现当我第一次遇到打印问题时,所有打印输出实际上都被发送到ipython控制台终端(在我的Linux机器上),而不是嵌入到笔记本电脑上。

Later on, I've found that when I was first having the printing problem, all print outputs were actually being sent to the ipython console terminal (on my Linux box), instead of being embed on the notebook.

这篇关于打印不显示在ipython笔记本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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