How to add a driver via python?
The error message gives a hint:

TypeError: driver_add() takes no keyword arguments

So pass the index as positional argument:

bpy.context.object.driver_add("location", 2)