No module named Image tk [closed]

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I am new to python can any body please Help

D:\python\sub>python app.py Traceback (most recent call last):   File "app.py", line 2, in      import ImageTk ImportError: No module named ImageTk 

回答1:

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 


回答2:

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.



回答3:

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.



回答4:

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.



回答5:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!