Question: How can I get dpkg PIL/Pillow version to work with python3.5 and python3-tk?
Problem: After rebooting my system after an update, my python3.5 tkinter codes which invokes PIL methods no longer works. The error message is:
Traceback (most recent call last):
File "/home/user1/.local/lib/python3.5/site-packages/PIL/ImageTk.py", line 176, in paste
tk.call("PyImagingPhoto", self.__photo, block.id)
_tkinter.TclError: invalid command name "PyImagingPhoto"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user1/Code/tkTreeview_test.py", line 37, in <module>
app = App(root, path=path_to_my_project)
File "/home/user1/Code/tkTreeview_test.py", line 22, in __init__
self.root_pic2 = ImageTk.PhotoImage(root_pic1)
File "/home/user1/.local/lib/python3.5/site-packages/PIL/ImageTk.py", line 115, in __init__
self.paste(image)
File "/home/user1/.local/lib/python3.5/site-packages/PIL/ImageTk.py", line 180, in paste
from PIL import _imagingtk
ImportError: cannot import name '_imagingtk'
After reading up similar questions (e.g. 1, 2, 3) and looking at the error msg, I think the above error msg is related to communication problem between PIL.ImageTk and Tcl in my .local/lib/python3.5/site-packages/PIL folder.
I have used Synaptic Package Manager to purge python3-pil, python3-pil.imagetk and python3-tk and reinstall them again. Also, I have tried to reinstall tk8.6 and tcl8.6. However, the same error msg still persist every time a run a code opening images via the PIL.ImageTk module.
Separately, I have checked that I can use tkinter.PhotoImage(file=i) from python3-tk to open image files. Image showed up w/o any error msgs. However, I use PIL.ImageTk.PhotoImage(i) to open the same image file i, my code fails with the above error msg.
Installed dpkg packages:
ii libtcl8.6:amd64 8.6.5+dfsg-2 amd64 Tcl (the Tool Command Language) v8.6 - run-time library files
ii tcl 8.6.0+9 amd64 Tool Command Language (default version) - shell
ii tcl8.6 8.6.5+dfsg-2 amd64 Tcl (the Tool Command Language) v8.6 - shell
ii libtk8.6:amd64 8.6.5-1 amd64 Tk toolkit for Tcl and X11 v8.6 - run-time files
ii tk8.6 8.6.5-1 amd64 Tk toolkit for Tcl and X11 v8.6 - windowing shell
ii tk8.6-blt2.5 2.5.3+dfsg-3 amd64 graphics extension library for Tcl/Tk - library
ii python3-tk 3.5.1-1 amd64 Tkinter - Writing Tk applications with Python 3.x
ii python3-pil:amd64 3.1.2-0ubuntu1 amd64 Python Imaging Library (Python3)
ii python3-pil.imagetk:amd64 3.1.2-0ubuntu1 amd64 Python Imaging Library - ImageTk Module (Python3)
ii python3-pilkit 1.1.13+dfsg-1 all Utilities and processors built for, and on top of PIL (Python3 version)
Installed pip packages: Using pip list and pip3 list, I found pilkit (1.1.13) and Pillow (3.2.0) installed. This mean I have Pillow (3.2.0) via pip and python3-pil:amd64 version 3.1.2-0ubuntu1 via dpkg install in my system. Is their coexistence causing a conflict and hence my problem?
I am stump by this problem and appreciate advice on overcoming the above mentioned error msg. Thanks