I have been using the following relative
approach to importing items:
from .utils import *
However, it doesn't seem to be working consistently, and I will often get the following error on both python3.6 and python3.7 (on both mac and ubuntu):
from .utils import *
ImportError: attempted relative import with no known parent package
The hack fix I have implemented is as follows:
try:
from .utils import *
except ImportError:
from utils import *
But this seems like the worst approach of all. Why does this error sometimes occur, and what would be the best approach to fix it?