No module named Image tk

Question:

I am new to python can any body please Help

D:pythonsub>python app.py
Traceback (most recent call last):
  File "app.py", line 2, in <module>
    import ImageTk
ImportError: No module named ImageTk
Asked By: Rakesh12

||

Answers:

You need to make sure that the ImageTK module has been installed. It is part of the Python Imaging Library (PIL) which can be found here

I would also suggest you read the official Python tutorial on Modules.

Answered By: timc

The code that you are using should be installed separately from the normal python installation, in fact comes from PIL libray (Python Imaging Library) which is an external library, an add on.

Beware that the PIL library doesn’t work on python version 3.0 and over, but is still working only on python 2.x series, so if you have python 3.x installed you should first install a python 2.x and than download and install the corresponding PIL Library.

Here a link to PIL library, you can download from here.

Answered By: piertoni

I had to import the PIL.ImageTk module separately. The line of code

      import PIL

did not import the PIL.ImageTk module and I had to additionally use

      from PIL import ImageTk

and then it worked fine in the Enthought Canopy 1.0 distribution of Python 2.7.

The need for that solution was suggested by this redhat bug resolution:https://bugzilla.redhat.com/show_bug.cgi?id=247171

This could also be accomplished with import PIL.ImageTk.

Answered By: Bennett Brown

This says that python is installed in non-standard location so the OS can not find ImageTk as it look in standard locations. You can re-install Python in a standard location, and where that is depends on which operating system and which installer you are using, or append this location to sys.path.
I’m using Ubuntu 13.04 and I simply install ImageTk package by using terminal like:

sudo apt-get install python-imaging-tk
Answered By: Zeb

For windows (with Anaconda and Python 3.x), the solution is proposed here :
Pillow installation for python 3.x [and Anaconda]

Install Pillow with pip after downloading the whl file

Answered By: Ursus
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.