在Python中使用tkinter导入图片时出现报错:_tkinter.TclError: couldn't recognize data in image file...

global photo
photo = PhotoImage(file="image/1.gif")
self.lable3 = Label(self, image=photo)
self.lable3.pack()

在方法中运行上述代码时,出现报错:

出现此类报错的原因在于“1.gif”文件,我首先是手动更改了照片的后缀“gif”,导致插入图片错误,

方法一:

在网上重新下载一个“gif”文件后,插入成功,更改后代码如下:

global photo
#photo = PhotoImage(file="image/1.gif")
photo = PhotoImage(file="image/2.gif")
self.lable3 = Label(self, image=photo)
self.lable3.pack()

代码正常运行

报错原因:tkinter第三方包下只能导入gif文件,直接更改文件后缀,并不能达到更改为gif文件的目的,改错的方法是重新导入一张gif文件。

方法二:

利用画图文件打开更改文件后缀的“1.gif”图片文件,将1.gif图片文件另存为gif文件(另存为gif文件之前的1.gif文件并非是真正的gif文件)

菜狗怯怯走过。。。

Python报错:_tkinter.TclError: couldn‘t recognize data in image file...相关推荐

  1. Linux命令行使用matplotlib,报错_tkinter.TclError: no display name and no $DISPLAY environment variable问题解决

    此文首发于我的个人博客:Linux命令行使用matplotlib,报错_tkinter.TclError no display name and no $DISPLAY environment var ...

  2. python报错:SyntaxError: Non-UTF-8 code starting with ‘\xe6‘ in file

    File "E:/project/python/learn/python/test.py", line 2 SyntaxError: Non-UTF-8 code starting ...

  3. python 报错 IndentationError: expected an indented block SyntaxError: invalid character in identifie

    红色方框那里敲击一个空格就好! 输入要在全英情况下! 另外,还要注意括号的事情.括号别出错误! IndentationError: expected an indented block的报错: Syn ...

  4. Python安装库较慢问题,Python报错pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool解决方法

    本文参考:https://blog.csdn.net/sinat_26811377/article/details/99698807 出现问题 在安装第三方库的时候,Python报错pip._vend ...

  5. 解决Python报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 658: illegal multibyte

    解决Python报错–UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 658: illegal multibyte ...

  6. python报错UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe8 in position 0 解决方案

    python报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 0 解决方案 参考文章: (1)python报 ...

  7. Python 报错 SyntaxError: invalid syntax 解决方法

    Python 报错 SyntaxError: invalid syntax 解决方法 参考文章: (1)Python 报错 SyntaxError: invalid syntax 解决方法 (2)ht ...

  8. python 报错 AttributeError: type object ‘datetime.datetime‘ has no attribute ‘datetime‘

    python报错:type object 'datetime.datetime' has no attribute 'datetime' 描述:在第一个python程序里还未报错,第二个程序完全复制过 ...

  9. Python报错TypeError: 'str' object is not callable

    原文:http://blog.sina.com.cn/s/blog_71f3890901017rsh.html Python报错TypeError: 'str' object is not calla ...

最新文章

  1. 云计算的服务模型 SaaS PaaS IaaS
  2. EXCEL2013保存时提示Be careful!Parts of your document may include personal information...
  3. openresty开发系列35--openresty执行流程之5内容content阶段
  4. IPV4 VS IPV6 谈谈省级ipv6的必要性
  5. 最全的 eclipse web 项目目录结构
  6. Cpp 对象模型探索 / placement new 实现原理
  7. 5月29日阿里云开发者大会了解一下?
  8. 如何看待2018年小米雷军98.18亿年薪?
  9. Spark SQL实战
  10. MPLS_×××入门中文版
  11. 算法效率的衡量方式 - 时间复杂度与空间复杂度
  12. Android 实现adb手机投屏
  13. (SEED-Lab)Buffer Overflow Vulnerability Lab缓冲区溢出实验
  14. mysql数据库全部大写吗_mysql中数据库名字分大小写吗
  15. 相机标定(基础)20221204
  16. C语言编程>第十三周 ⑧ 已知学生的记录由学号和学习成绩组成,M名学生的数据已存入stu结构体数组中。请编写函数fun,该函数的功能是:
  17. 如何写一个魔方二维动态还原MATLAB仿真程序
  18. 2020年远程面试全攻略
  19. 【判断题】【简答题】【数据库原理】
  20. 【刚好遇见Kotlin】使用Kotlin开发——搭建Kotlin 编译环境

热门文章

  1. 个税专项附加扣除操作指引
  2. C语言入门一对一陪学
  3. 计算机u2.0接口在哪,USB2.0和USB3.0的USB接口区别在哪里?怎么分辨?
  4. python字符串方法的简单使用
  5. 骨感蓝牙耳机什么品牌的好?骨感耳机最好的品牌推荐
  6. H7-TOOL发布V2.10, RTT增加搜索范围, 脱机烧录增加华大, 雅特力, 航顺,复旦微和nRF51新型号, 一键下载, HEX分段等(2021-12-29)
  7. [siggraph13]《使命召唤:黑色行动2》的光照技术
  8. 巧用try、catch实现JS代码加密
  9. 常用的Excel快捷键
  10. java 基础类型转换_java基础之基本数据类型及之间的转换