'why cant i install ImageTk

I'm getting into Tkinter and I'm trying to put images into the windows it makes, but wherever I search the internet all I find is that I need a module called ImageTk. I've tried installing this module and it doesn't work, I've got PIL and Pillow installed but ImageTk just won't install and I have no idea why.

I'm relatively new to Tkinter and my understanding of it is limited, so I'm sorry if it's an obvious problem.

Whenever I try to install I get the following:

Selecting previously unselected package python3-pil.imagetk:armhf. dpkg: unrecoverable fatal error, aborting: files list file for package 'qdbus' is missing final newline E: Sub-process /usr/bin/dpkg returned an error code (2)



Solution 1:[1]

  1. Install Python Imaging with Tkinter support:

    sudo apt-get install python-imaging-tk
    
  2. In the code:

    from PIL import ImageTk, Image
    

Solution 2:[2]

Next advice helped me, after that I was able to import ImageTk from PIL:

# python 2
sudo apt-get install python-imaging python-pil.imagetk
# python 3
sudo apt-get install python3-pil python3-pil.imagetk

reference: https://www.codegrepper.com/code-examples/whatever/how+to+install+imagetk+in+python

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Artur Barseghyan
Solution 2