TypeError: Converting py args to operator properties: enum "LocRotScale" not found in () So I've got this row of code: (line 115)

bpy.ops.anim.keyframe_insert(type='LocRotScale', confirm_success=True)


And it produces this error message:

Traceback (most recent call last):
  File "D:\{super secret path}\lab1.blend\lab1", line 115, in &lt;module&gt;
  File "D:\Windows Programs\Blender\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 ()


Problem is, this exact code worked just a minute ago, i ran it once, cleared the keyframes from the time line and atempted to run the script again, then this error occured and its been this way ever since. 
I've tried both restarting blender, restarting the pc and even reinstalling blender (through the 64bit msi installer, repair mode).

I've even tried running the same code on a different machine, and that works.


Why do i get this error, and how do i fix it? 

System Info:

OS: Windows 10 Home - v1607 
Blender: v2.78a
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')