My project structure looks like this:
project/
main.py
sub_a/
class_a.py
__init__.py
utils/
__init__.py
util_a.py
sub_b/
class_b.py
__init__.py
utils/
__init__.py
util_b.py
And in each of class_a.py, class_b.py, there is an import like this:
from utils import util_a/b
My PYTHONPATH points to both sub_a and sub_b. When I try to
import class_b
in main.py, I get an ImportError:
ImportError: cannot import name util_b
I am using Python 2.7.
I understand that the error comes about because from utils import util_b is ambiguous, so Python chooses the first one on the path, but how can I rewrite the imports so that they work?
I don't think changing the PYTHONPATH is an option, since each of sub_a and sub_b assume they are part of the PYTHONPATH in their own internal imports. For instance, the from utils import util_b in class_b.py.