'How do I import a package and run a module in it, it will import another module in the package

Module b in the package will import module a. If I import this package in c.py and run module b, it will report an error.

No module named 'a'

How should I modify it?

a.py:

def a():
    print('a')

b.py:

import a
a.a()

c.py:

import package.a
import package.b

Directory structure:

main/
    c.py
    package/
       __init__.py
        b.py
        a.py


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source