Martin Panter added the comment:

It sounds like you are trying to do a plain “import email”, and then expect all 
the submodules under that package to work, including “email.mime.nonmultipart”. 
That is not how it works. I understand the submodules and subpackages are only 
initialized if you ask for them explicitly. Hence the “no attribute 'mime' ” 
error in 3.4.

In your case perhaps you should change or extend the import statement to do

import email.mime.nonmultipart

The reason why your “from . . . import” works is it also initializes the 
submodule that you want, and stores it in a chain of attributes of the 
top-level module as a side effect.

Quickly scanning through 
<https://docs.python.org/3/tutorial/modules.html#packages>, 
<https://docs.python.org/3/reference/import.html#packages>, 
<https://docs.python.org/3/reference/simple_stmts.html#import>, I didn’t see 
anything obvious pointing out that importing a top-level package doesn’t 
completely initialize the whole thing. But maybe there is something already 
there. You might have to read about how the __init__.py internals work to pick 
it up.

----------
nosy: +martin.panter

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24949>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to