python import module from parent package

danielrvt picture danielrvt · Jan 10, 2013 · Viewed 20.3k times · Source

I have the following directory structure

foo/
    __init__.py
    settings.py
    bar/
        __init__.py
        myfile.py

In myfile.py I have: import settings

I get the following error: ImportError: No module named settings, why? How can I efectively import the settings file from myfile.py

Answer

Adrián picture Adrián · Jan 10, 2013