[英]PIL image show() doesn't work on windows 7
I would like to show an image using python on windows and other platforms. 我想在Windows和其他平台上使用python显示图像。 When I do:
当我做:
from PIL import Image
im = Image.open('image.png')
im.show()
my default viewer opens up and tells me that Windows Photo Viewer can't open this picture because either this file was deleted
, etc. 我的默认查看器打开并告诉我
Windows Photo Viewer can't open this picture because either this file was deleted
等。
The file is probably deleted because PIL calls the os with the following command: "start /wait %s && del /f %s" % (file, file)
该文件可能已删除,因为PIL使用以下命令调用操作系统:
"start /wait %s && del /f %s" % (file, file)
I found a workaround here . 我在这里找到了解决方法。 They recommend changing PIL's code to
"start /wait %s && PING 127.0.0.1 -n 5 > NUL && del /f %s" % (file, file)
. 他们建议将PIL的代码改为
"start /wait %s && PING 127.0.0.1 -n 5 > NUL && del /f %s" % (file, file)
。 However, I want others to be able to use my code. 但是,我希望其他人能够使用我的代码。
Is there a simple solution? 有简单的解决方案吗? Should I look for an alternative to PIL that would work crossplatform?
我应该寻找可以在跨平台上工作的PIL的替代方案吗?
If you want it to be opened by MS paint only, you can use: 如果您只想通过MS paint打开它,您可以使用:
start /wait mspaint %s && del /f %s" % (file, file)
The /wait
is not having any effect when the file name is specified directly. 直接指定文件名时,
/wait
没有任何影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.