无法在ubuntu中显示IPython对象,但在colab输出中显示

无法在ubuntu中显示IPython对象,但在colab输出中显示,python,image,ubuntu,ipython,display,Python,Image,Ubuntu,Ipython,Display,我在“test”文件夹中有一堆图像,我在一个文件中有一个python代码来显示这些图像。这是密码 import torch from IPython.display import Image, clear_output import matplotlib import glob import PIL from IPython.display import Image, display from io import BytesIO print("hi") for imageN

我在“test”文件夹中有一堆图像,我在一个文件中有一个python代码来显示这些图像。这是密码

import torch
from IPython.display import Image, clear_output
import matplotlib
import glob
import PIL
from IPython.display import Image, display
from io import BytesIO

print("hi")
for imageName in glob.glob('test/images/*.jpg'): #assuming JPG
  print("in \n")
  display(Image(filename=imageName)) #displaying successfully in colab
  print("out")
  print("\n")
这是我在ubuntu终端上运行python文件时的输出


我没有打开其他选项卡来显示图像。我在堆栈溢出中尝试了其他答案,但没有成功。但是,图像在colab的输出中是可见的。

如果在终端中运行,终端只能显示文本。 因此,
显示(图像(…)
无法显示您的图像

display
Image
实际上是以IPython/Jupyter为中心的实用程序,在使用纯Python时无法完全正常工作

如果您想在终端中运行时显示图像,则需要使用或之类的命令,并要求他们打开一个包含图像的新窗口,根据您的操作方式,您可能需要关闭窗口以使程序继续执行


你也可以在本地运行
jupyter笔记本
(或者,
jupyter实验室
),打开一个支持图像的web界面。

这篇文章可能对@waveshapper有所帮助。我读过那篇文章,但它对我没有帮助。我可以在colab的输出中看到图像,但当我在终端中运行它时,在ubuntu中看不到。