Tkinter: cannot import name '_imagingtk'的解决办法

来源:互联网 发布:linux git 配置文件 编辑:程序博客网 时间:2024/06/05 06:02

关于Tkinter中display an image in a label  ,原生PhotoImage语句的image格式只支持gif,

为了能够加载JPG格式,需要这样操作:

img = PhotoImage(file='myimage.gif')
替换成

from PIL importImage, ImageTk

img =ImageTk.PhotoImage(Image.open("myimage.jpg"))

label['image'] = img

但是在这个过程中出现了如下错误:

ImportError:cannot import name '_imagingtk'

在stackoverflow中搜索了一些类似问题,经尝试可以这样解决:

pip install –I pillow

pillow安装完成后重启IDE

我使用的是Python 3.4.3 |Anaconda 2.3.0 (64-bit)

0 0
原创粉丝点击