使用pyinstaller打包后运行时报错OSError: IOError: broken data stream when reading image file

(一)

使用PIL和Pillow处理图片时,出现如下错误:

IOError: broken data stream when reading image file

错误的原因有可能是:
1.import tf和import PIL的顺序有问题
2.图片本身受损

第一种解决方法:调换顺序即可。
第二种解决方法如下:

from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

(二)

打开文件,进行写操作,报错 OSError: [Errno 29] Illegal seek

f = open(save_file_dir,'a')
OSError: [Errno 29] Illegal seek

经过检查发现是因为save_file_dir的类型不对,正确应该是string类型
原文地址为https://blog.csdn.net/fengzhongluoleidehua/article/details/85949173

发布了84 篇原创文章 · 获赞 29 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_39852676/article/details/101707699