Duplicating an object in script (by name)
bpy.ops is a module directly in bpy, not part of any object class. It holds all registered operators. If you don't specify a region, it will always assume you want to do something in the viewport. Just replace src_obj with bpy to match the behavior of ShiftD.
You should also make sure that the cube is the active object.
bpy.context.view_layer.objects.active = src_obj
scr_obj.select_set(True)
bpy.ops.object.duplicate(linked=0,mode='TRANSLATION')
new_obj = bpy.context.active_object