How to set skin_root_mark on selected vertices of a skinned mesh generated in Python?
As said in comment, the object is not active and that's why the ops failed.

You may use:

bpy.context.view_layer.objects.active = obj 


before the ops.

Though you can also without ops:

# Add the skin modifier
obj.modifiers.new(name="SK", type="SKIN")

#Get the skin vertices layers
skin_vertices = obj.data.skin_vertices
#Get the layer
skin_layer = skin_vertices[0]

#Assigns radius to some vertices
skin_layer.data[0].radius = (0.20,0.20) #Indices 0 and 1 are the vertex indices
skin_layer.data[1].radius = (0.10,0.10)

#Assigns root
skin_layer.data[1].use_root = True
#Assigns loose
skin_layer.data[1].use_loose = True


Also note that, this way you can assign multiple roots which is not allowed from the UI. I don't know if this can lead to issues or not.