"bpy.ops.rigidbody.world_add.poll() failed, context is incorrect" occurs when python script is ran more than once I am seeing a context incorrect error if I run this script more than once in the same .blend file.  It  occurs in Blender 2.82 and 2.90.  My understanding of how contexts work is only mediocre but I cannot think of a reason why/how the context would change after running the script multiple times.  I also do not know of any context requirements for trying to add a rigid body world.  My end goal is to enable rigid body physics for specific objects and I'm pretty sure enabling rigid world is the first step. I've reduced the code to the following:
import bpy
bpy.ops.rigidbody.world_add()

Reproduction steps:

Open a new general blend file.
Insert code from above, run once.  There will be no error and the rigid body world will be enabled if you look in the &quot;scene tab&quot;
Run the script again, error will say context is incorrect.

Thanks.
When you first start Blender there is no rigid body world added to the context. You can check this by running print(C.scene.rigidbody_world) in the console. This should return None
When you run bpy.ops.rigidbody.world_add() you are adding a new rigid body world to bpy.context.scene If you now enter print(C.scene.rigidbody_world) you should get something like &lt;bpy_struct, RigidBodyWorld at 0x00000225720128B8&gt;
If you immediately run bpy.ops.rigidbody.world_add() again the error you get should be something like RuntimeError: Operator bpy.ops.rigidbody.world_add.poll() failed, context is incorrect This tells us that the operator's poll() method is checking &quot;something&quot; in the context and since we know that what has changed is that we now have a rigidbody_world in our context, we can assume that this is what the poll function is checking for. (actually checking this is a bit of a pain as it means tracking down the operator)
Wrapping up - you have two options.

remove the rigidbody world using bpy.ops.rigidbody.world_remove() before rerunning your script
Check if there is already a rigidbody world added before adding one and skipping if there is.