scipy 在 okular 中打开图像

scipy opening image in okular

每当我尝试使用 scipy 显示图像时,它都会以 okular 格式打开图像,并在 Could not open /home/username/%i 上方弹出一个错误对话框。这是我正在执行的代码:

    from scipy import misc
    f = misc.imread('images.jpeg')
    misc.imshow(f)

这有点烦人,因为我使用 okular 查看我的 pdf 文件。如果我卸载 okular 并执行相同的操作,图像将在 tcl window 中打开,这没问题。

docs 告诉您可以通过定义 environment-variable SCIPY_PIL_IMAGE_VIEWER.

来更改使用的查看器

您可以在您的系统上全局更改此设置,也可以在您的代码中执行此操作,如下所示:

import os
os.environ["SCIPY_PIL_IMAGE_VIEWER"]="display"  # i'm not sure what you want here