Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top