How to Install Pil with Pip?
When I Run the Following from Tkinter Import * from Pil Import Imagetk, Image Root. Mainloop() I Got Traceback (Most Recent Call Last): File "Image_Viewer...
when I run the following
from tkinter import *
from PIL import ImageTk, Image
root.mainloop()
I got
Traceback (most recent call last):
File "image_viewer.py", line 2, in <module>
from PIL import ImageTk, Image
ImportError: No module named PIL
but I already install Pillow and everything is fine.
2 Answers
Use Pillow which is the "new" or the replacement of PIL, but has the same-named modules to preserve compatibility:
pip install pillow
Also, as suggested in the comments, maybe you are just using the wrong python binary, try to check if you're in/out of a virtual environment or check differences between python vs python3 vs python2 on your system:
python -m pip list
python2 -m pip list
python3 -m pip list
If you are sure that you already installed pillow use this command pip install pillow --upgrade, then you can use the command pip freeze to list all modules that have been installed.