Fix python "Attempted relative import in non-package"

You can launch your script with the '-m' argument:
python -m ca.i88.tests.example

if __name__ == '__main__':
    if __package__ is None:
        import sys
        from os import path
        sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
        from ca.i88 import myfunc
    else:
        from ..ca.i88 import myfunc

Comments

Popular posts from this blog

How to delete / clear queue of PowerMTA