[Tutor] Why can't I import this?

Kent Johnson kent37 at tds.net
Wed Nov 29 04:20:05 CET 2006


Dick Moores wrote:
> I just discovered something for Tkinter that I want to use. It's a 
> Tooltip class, at <http://tkinter.unpythonic.net/wiki/ToolTip> .
> 
> I've copied it to a file I named toolTipDemo.py and put it with a 
> couple of other files I use as modules. They're in
> E:\Python25\Lib\site-packages\mine. One file there is intSpell.py, 
> and I can import it by
> 
> from mine.intSpell import intSpell
> 
> With no problem:
>  >>> from mine.intSpell import intSpell
>  >>>
> However, the same method of importing doesn't work with toolTipDemo:
>  >>> from mine.toolTipDemo import toolTipDemo
> Traceback (most recent call last):
>    File "<string>", line 1, in <string>
> ImportError: cannot import name toolTipDemo

Try
from mine.toolTipDemo import demo

mine.toolTipDemo points to the module, then you need to reference a name 
defined in the module. (You must have something called intSpell in 
intSpell.py.)

Kent



More information about the Tutor mailing list