Your original code should have been using "import mypkg.models" or "from
mypkg import models" instead of "import models". The last one is ambiguous
because it doesn't know which package to look in (and will not work on
py3). This works for you previously because views.py and models.py were in
the same subpackage and you're on py2 and as such python attempts to import
that module from the same subpackage.

Now that they are no longer in the same subpackage, you *must* be more
specific with what module you want to import. For example "from mpkg.models
import models". Alternatively you could use relative imports via "from ..
import models".

There are benefits to both the absolute and relative approaches but either
way you should not treat your subpackages or submodules as top-level
packages. It is explicitly unsupported in py3 and in py2 when using "from
__future__ import absolute_imports".



On Thu, Mar 20, 2014 at 2:52 PM, Zagloj <[email protected]> wrote:

>  Hi, I have a problem following the docs, I simply tried to modify the
>  structure from my scaffold but with no success, I followed these steps:
>
>  1: Create the directory views and move the views.py to it
>  2: Create empty __init__.py inside views directory
>
> I install it (/env/python setup.py develop) and then the test
> (/env/python setup.py test) fail complaining about a lot of files, then
> one last error: AttributeError: 'module' object has no attribute 'views'
>
> When running pserve it complains about a lot of files and then:
>
> ImportError: No module named models
>
>  Any help/hint/doc would be much appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to