Warning when applying modifier via Python?
No errors here. Make sure that the context is set to Object Mode and save the file:

import bpy

# set context
bpy.ops.object.mode_set(mode='OBJECT')

# get active object
target = bpy.data.objects['Icosphere']
bpy.context.scene.objects.active = target

# apply modifier
bpy.ops.object.modifier_apply(modifier="Subsurf") # apply_as='DATA'

# save the file
bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath)


Command line:

blender -b &lt;path-to-blend-file&gt; --python &lt;path-to-python-script&gt;