为什么我的 os 无法打开新的 window 来显示图像?
Why my os can't open a new window to show the image?
我已将默认应用程序 --gimp 设置为在我的 os (debian 11 + lxde) 中打开图像。
下面的 python 代码将在您的默认图像查看器中打开图像:
open a new window to show image
>>> from PIL import Image
>>> img = Image.open('test.png')
>>> img.show()
为什么在我的 os 中执行时没有打开新的 window 并且 gimp 开始显示图像?
在 Debian 中安装 matplotlib 运行 sudo apt install python3-matplotlib
。使用matplotlib Python模块中的pyplot来显示图像如下。
import matplotlib.pyplot as plt
from PIL import Image
plt.imshow(Image.open('test.png'))
plt.show()
或者使用 sudo apt install eog
安装 eog,您的原始代码将在新的 window 中显示图像。请注意,如果图片很小,那么新 window 也会很小,您可能不会注意到它已打开。
我已将默认应用程序 --gimp 设置为在我的 os (debian 11 + lxde) 中打开图像。
下面的 python 代码将在您的默认图像查看器中打开图像:
open a new window to show image
>>> from PIL import Image
>>> img = Image.open('test.png')
>>> img.show()
为什么在我的 os 中执行时没有打开新的 window 并且 gimp 开始显示图像?
在 Debian 中安装 matplotlib 运行 sudo apt install python3-matplotlib
。使用matplotlib Python模块中的pyplot来显示图像如下。
import matplotlib.pyplot as plt
from PIL import Image
plt.imshow(Image.open('test.png'))
plt.show()
或者使用 sudo apt install eog
安装 eog,您的原始代码将在新的 window 中显示图像。请注意,如果图片很小,那么新 window 也会很小,您可能不会注意到它已打开。