[Tutor] import'ing problems (path) P.S.!!
dyoo at hkn.eecs.berkeley.edu
Mon Oct 11 20:11:15 CEST 2004
On Tue, 5 Oct 2004, Tim Johnson wrote:
> * Kent Johnson <kent_johnson at skillsoft.com> [041005 10:51]:
> > It looks like WebKit doesn't want to see the Webware level in the package
> > hierarchy. You could take everything out of the Webware directory and put
> > it directly in site-packages or add the Webware directory to sys.path as I
> > described before. Then try import WebKit.Page (without the WebWare prefix).
> Okay! add the following line:
> and the import is successful.
Ok, then this sounds like Webware has some silly problems with their
Let me double check a few things... oh my goodness. That doesn't look
right! There are some places in the WebKit that do some wacky imports.
For example, Webware.WebKit.Object:
import os, sys
# When the Webware tarball unravels,
# the components sit next to each other
from MiscUtils.NamedValueAccess import NamedValueAccess
They should not be dynamically fiddling with the system path like that!
They may need to rewrite that as:
from Webware import *
Since they designed the Webware package to be 'from [module] import *'
safe, they might as well use it. *grin*
According to section 6.4.2 of the Python Tutorial (Intra-package
any module in the Webware.WebKit subpackage won't automatically see stuff
at the toplevel Webware package. That's why they're running into import
But it looks like, rather than fixing the problem cleanly, they kludged a
solution that only works if the current working directory is at the
toplevel Webware directory. Argh.
So the Webware developers to fix that; Webware needs to correct they way
they import packages. The inner modules in ther should definitely NOT
make changes to the sys.path variable.
Hope this helps!
More information about the Tutor