from mypkg import a
is the correct form. Don't run scripts from inside the Python package directory, it makes the same module available using multiple names that may lead to bugs. Run python -m mypkg.b
from the directory that contains mypkg
instead.
To be able to run from any directory, mypkg
should be in pythonpath.