Complete re-edit of the question to make it less broad. How do you make a script when executing at blender start-up not throw any errors about scene context
AttributeError: '_RestrictedContext'
This script works when run from a blend file. The script imports a none blend file object
Simple?