tags:

views:

123

answers:

2

I'm trying to package my modules, but I can't seem to get it working.

My directory tree is something like the following:

snappy/
    __init__.py
    main/
        __init__.py
        main.py
        config.py
        ...
    ...

and the code I'm using is

from snappy.main.config import *

I'm getting the error:

ImportError: No module named snappy.main.config

Any ideas what's going wrong? This is using Python 2.5 on Ubuntu 8.10.

Thanks in advance for your help.

+4  A: 

Is the parent directory of snappy in sys.path? If it's not, that's the only thing I can think of that would be causing your error.

David Zaslavsky
+4  A: 

It depends on where your script using the import resides and your system PYTHONPATH. Basically, to have that import working you should run your script (the one having the import) in the parent directory of snappy or your script should change sys.path to include it.

./alex

alexpopescu
Thanks a lot for your help!
Donald Harvey