Python ImportError: cannot import name '_imagingtk' in virtualenv

偶尔善良 提交于 2019-12-06 03:30:53

So i had this same problem for the last few days and finally got it resolved. I am running Ubuntu 14.04 as well and i believe i am running python 2.7. The code that I was running was the following

from Tkinter import *
from PIL import Image, ImageTk

app_root = Tk()
img = ImageTk.PhotoImage(Image.open("detailedmodel.jpg"))

imglabel = Label(app_root, image=img).grid(row=1, column=1)

app_root.mainloop()

This was generating the error:

ImportError: cannot import name _imagingtk

I tried a few different things to solving this error based on other solutions online, generally just uninstalling and installing pillow with different developer libraries but the script kept crashing with the same error. Finally I found that in the terminal entering:

sudo pip2.7 install -I --no-cache-dir Pillow

seemed to solve the problem. With the other installs I guess I was working with the wrong version of pillow for python 3 not 2.7.

Hope this helps but it looks like you might have solved the problem already.

Delete PIL and Pillow packages in lib-packages in your python directory: I am using Conda Env, so

conda remove PIL

and

conda remove pillow

or Delete them directly in lib-packages dir (Suggestion: Make a backup folder).

then, install pillow in this site : http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg. If you using Windows Platform install PIL this site : http://www.pythonware.com/products/pil/ (choose based your python version).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!