Camera animation doesn't rotate along shortest path
Instead of rotating around a global axis with rotate_axis set absolute values to the rotation channels and handle all the relative transformations in code.

camera.rotation_euler = (math.pi/2, 0, 0)
camera.keyframe_insert(data_path="rotation_euler", frame=0.0)

prevRot = camera.rotation_euler
nextRot = (prevRot[0], prevRot[1], prevRot[2] + 2 * math.pi)
# or absolute values
# nextRot = (math.pi/2, 0, 2*math.pi)

camera.rotation_euler = nextRot
camera.keyframe_insert(data_path="rotation_euler", frame=frames)


The script presumes Y is Up.