为什么IPython.display.Image不显示在输出中?
我有一个像这样的细胞:为什么IPython.display.Image不显示在输出中?,python,ipython,Python,Ipython,我有一个像这样的细胞: from IPython.display import Image i = Image(filename='test.png') i print("test") 输出仅为: test 我在输出中没有看到图像。我检查了文件是否存在(无论如何,如果它不存在,您会得到一个错误) 有什么线索吗?用 i = Image(filename='test.png') 仅创建要显示的对象。对象通过以下两个操作之一显示: 直接调用IPython.display.display(obj)
from IPython.display import Image
i = Image(filename='test.png')
i
print("test")
输出仅为:
test
我在输出中没有看到图像。我检查了文件是否存在(无论如何,如果它不存在,您会得到一个错误)
有什么线索吗?用
i = Image(filename='test.png')
仅创建要显示的对象。对象通过以下两个操作之一显示:
IPython.display.display(obj)
,例如
from IPython.display import display
display(i)
displayhook
,它自动显示单元格的结果,也就是说将i
放在单元格的最后一行。示例中的lonei
不会显示,因为它不是单元格中的最后一项。因此,虽然这不会显示图像:
i = Image(filename='test.png')
i
print("test")
这将:
i = Image(filename='test.png')
print("test")
i
get_ipython().magic(u'matplotlib inline')
它将启用用于IPython笔记本的内联后端
查看更多和。查看代码后,我可以说,在Windows下,从IPython 7.1.0开始,只有
%matplotlib inline
支持此功能,而在交互式IPython shell下不起作用
Jupyter中有额外的代码。以下示例适用于
jupyter qtconsole
jupyter笔记本
原则上,但只能通过外部程序,例如,临时文件被删除jupyter控制台
def测试_显示()
导入pyx
c=pyx.canvas.canvas()
圆=pyx.path.circle(0,0,2)
c、 笔划(圆圈,[pyx.style.linewidth.Thick,pyx.color.rgb.red])
返回c
显示(测试显示()
这并不是问题的答案。若要评论或要求作者澄清,请在其帖子下方留下评论。-是的,我会解决这个问题。我得到了AttributeError的错误:“NoneType”对象没有属性“magic”你是在交互模式还是jupyter笔记本中?我只得到了