Library import succeeds with nose, fails elsewhere

richmolj at gmail.com richmolj at gmail.com
Sat Apr 25 13:48:23 EDT 2015


Apologies, I'm a rubyist and this is a beginner question but I'm not finding a great answer with lots of googling. I am writing a library, organized something like this:

awesome_lib/awesome.py
awesome_lib/util/__init__.py
awesome_lib/util/helper.py

In the top of awesome.py:

foo = 'bar'
import helper

In the top of helper.py:

import awesome
print awesome.foo

IRL, I'm doing this for things like referring to the main logger from within the utility method.

This works great when running tests through nose. In a test file I 'import awesome', refer to awesome.helper and everything is fine.

If I try to put this library into a project, however, the import fails:

~/foo.py
~/awesome_lib

'python foo.py' (only code is 'from awesome_lib import awesome')
 ImportError: No module named awesome

The error occurs when importing the helper and it tries to 'import awesome' and fails.

I'm sure I am doing something stupid, can someone point me in the right direction?



More information about the Python-list mailing list