0

So I'm trying to open an image using PIL, resize it, and put it on a tkinter canvas. I've tried importing TkImage:

import TkImage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'TkImage'

from PIL import TkImage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TkImage'

from PIL.Image import TkImage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TkImage'

from PIL.Image import Image
i = Image.TkImage()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Image' has no attribute 'TkImage'

All these raise exceptions. Could someone please help?

Jacob
  • 225
  • 1
  • 8
  • Please add the error messages/exceptions to your question. – Rafael Dec 30 '19 at 18:37
  • 1
    There is nothing named `TkImage`. Did you read some documentation showing something named `TkImage`? Are you wanting to use `ImageTk`? – Bryan Oakley Dec 30 '19 at 18:41
  • That won't work either @BryanOakley – Jacob Dec 30 '19 at 18:42
  • 1
    What does "won't work" mean? You absolutely can import `ImageTk` from PIL. – Bryan Oakley Dec 30 '19 at 18:44
  • It raises an error if I try to import it alone, too @BryanOakley – Jacob Dec 30 '19 at 18:45
  • 1
    Please show the error. Though, just throwing random characters at an `import` statement isn't the right way to solve the problem. There is plenty of documentation showing how to import PIL and its components. – Bryan Oakley Dec 30 '19 at 18:45
  • Here is the error that raises when I try to import ImageTk: `Traceback (most recent call last): File "", line 1, in ImportError: No module named 'ImageTk'` – Jacob Dec 30 '19 at 18:47
  • 1
    Are you sure that PIL has been correctly installed on your system? Try `pip install Pillow` in a shell window (command window on Windows), and see if the (re)installation processes without errors. – sciroccorics Dec 30 '19 at 19:07
  • Does this answer your question? [ImportError: No module named PIL](https://stackoverflow.com/questions/8863917/importerror-no-module-named-pil) – stovfl Dec 30 '19 at 19:36
  • What is your Pillow version? Please [edit] your post to show _all_ relevant info, including the new error messages and the current output of `pip show Pillow`. – Gino Mempin Dec 31 '19 at 02:14

1 Answers1

0

There is nothing named TkImage in PIL. There is something named ImageTk, however.

from PIL import ImageTk
Bryan Oakley
  • 310,202
  • 36
  • 445
  • 584