TypeError: Converting py args to operator properties: enum "LocRotScale" not found in ()
The context object needs to be in 'OBJECT' or 'POSE' mode to run bpy.ops.anim.keyframe_insert(type='LocRotScale', confirm_success=True)

Test in python console, in 'OBJECT' mode

&gt;&gt;&gt; bpy.ops.anim.keyframe_insert(type='LocRotScale', confirm_success=True)
Info: Successfully added 9 keyframes for keying set 'LocRotScale'
{'FINISHED'}


In 'EDIT' mode:

&gt;&gt;&gt; bpy.ops.anim.keyframe_insert(type='LocRotScale', confirm_success=True)
Traceback (most recent call last):
  File "&lt;blender_console&gt;", line 1, in &lt;module&gt;
  File "/home/batfinger/src/BlenderGIT/qtcreator_build/bin_current/2.78/scripts/modules/bpy/ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties:  enum "LocRotScale" not found in ('Available')