I am trying to load in an image from the same folder as the one my python script is in.
# create a class called Person
# create init method
# 2 attributes (
For Debian/Ubuntu:
Python 2
sudo apt-get install python-imaging python-pil.imagetk
Python 3
sudo apt-get install python3-pil python3-pil.imagetk
For Archlinux:
sudo pacman -S python-pillow
It will install the package and you can use it: from PIL import ImageTk
I tried this to install Pillow itself and it works well, i didn't use sudo.
$ pip install Pillow --user
Source for the main installation guide: here
Feel free to edit my answer/correct me.
You will have to change the code like this:
import PIL
from PIL import ImageTk
from PIL import Image
It should work fine!
sudo apt-get install python3-pil.imagetk
It worked for me!
Got it figure out! You must import them separately and not on one line.
from PIL import Image
from PIL import ImageTk
Insead of
from PIL import Image, ImageTk
Python does act up a little when importing TkImage and Image together. You need to import the PIL first and then import TkImage and Image individually like below-
import PIL
from PIL import TkImage
from PIL import Image
This should work fine. You can also check if the pillow is installed in your system correctly by using command prompt like below-
import PIL