Digital Marketing

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
        from import myfunc


Popular posts from this blog

How to fix Google Apps Script: Script function not found: doGet

Creating sort index in MySQL

How to fix: df shows no file systems processed on Linux