Library import succeeds with nose, fails elsewhere

richmolj at richmolj at
Sun Apr 26 01:36:39 CEST 2015

Thanks, I appreciate the help. I did figure this out.

Chris - apologies for the error in my example, it should have been 'import util' within IOW, I was looking for awesome.util.helper to be available, and I also wanted available within

The solution ended up being editing the top-level

import awesome

and then *when in a subdirectory*:

import awesome_lib as awesome

and *when in a different top-level file*:

import awesome.

IOW (from what I can tell) I made importing the package the same as importing this one file. When in a subdirectory import via the package, when in a sibling file import the file directly.

This certainly feels odd, and I did find some (likely preferred) different ways I could handle it. My intent was that now I can refer to awesome.util.helper regardless of where I am (outside the package, within different directories, etc). My guess is that doing things like importing 'helper' directly and referring to it as 'helper' (no awesome.util prefix) is the python way of doing things, just didn't ring true with my background.

More information about the Python-list mailing list