bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) works manually (by using mouse and keyboard) but not using bpy Traceback (most recent call last):
  File &quot;\Text&quot;, line 8, in &lt;module&gt;
  File &quot;C:\Program Files\Blender Foundation\Blender 2.90\2.90\scripts\modules\bpy\ops.py&quot;, line 201, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.view3d.snap_selected_to_cursor.poll() failed, context is incorrect
Error: Python script failed, check the message in the system console

I am typing in this command, because I already got selected object before snapping:
bpy.ops.view3d.snap_selected_to_cursor(use_offset=False)

The question is: why I can not snap selected object to 3d cursor using bpy python while being able to do it by using mouse and keyboard?
as @lemon says the answer is override the context
import bpy
for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        override = bpy.context.copy()
        override['area'] = area
        override['region'] = area.regions[4]
        bpy.ops.view3d.snap_selected_to_cursor( override, use_offset=False)