[Tutor] can't import module

Dave S pythontut at pusspaws.net
Sun Jul 2 12:55:24 CEST 2006


On Sunday 02 July 2006 11:29, Kent Johnson wrote:
> Dave S wrote:
> >  > dave at dave-comp:~/my_files/my_gg/gg1.4/get_data$ ./live_datad.py
> >
> > Traceback (most recent call last):
> >   File "./live_datad.py", line 15, in ?
> >     from logger import log
> > ImportError: No module named logger
> >
> > dave at dave-comp:~/my_files/my_gg/gg1.4/get_data$ echo $PYTHONPATH
> > /home/dave/my_files/my_gg/gg1.4/configs:/home/dave/my_files/my_gg/gg1.4/l
> >ogs:/home/dave/my_files/my_gg/gg1.4/get_data:/home/dave/my_files/my_gg/gg1
> >.4/gg_utils:/home/dave/my_files/my_gg/gg1.4/ipc:/home/dave/my_files/my_gg/
> >gg1.4/process_data:/home/dave/my_files/my_gg/gg1.4/common_utils
>
> I don't know why your import is failing, but from your PYTHONPATH it
> looks like you should consider making all the gg1.4 directories into
> packages,
> then you would have imports such as 
> from gg_utils.logger import log
>
> This would simplify PYTHONPATH and I think reflect more accurately what
> you are doing.
>

Thanks for replying :)

The app is fairly big and distributed around the gg1.4 directory. I get the 
feeling that 'from logger import log' is the first of a lot of import 
problems, this script alone imports from another 7 modules

from urllib import urlopen
from time import strftime
from cPickle import dump
from datetime import datetime, time, timedelta
from os import remove

from logger import log
from html_strip import html_strip
from garbage_collect import garbage_collect
from valid_day import valid_day
from exact_sleep import sleep_delay,sleep_until
from cookie_string import cookie_string
from data_core import Data_Core

from config import data_dir,HTML_addr, ipc_dir

As far a putting everything into a package - I am a bit lost. Do you mean one 
big .py script or am I misunderstanding you ?

Dave



> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list