Very simple animation handler script and console print not working on Mac

Hi, i’m starting to code with python on Blender, and with this very basic script i just try to rotate a cube by 5 degrees at each frame automatically during playback. I run the script. The test initialisation works (the first lines where i put the Y rotation to 45, the cube rotates correctly).
The first “print” function doesn’t show anything in the console. There are no errors reported though. Then, i play the animation in the viewport.
There are still no errors, but none of the “print” functions show anything, and the cube doesn’t rotate. I’m on mac, tested with blender 2.82 and 2.83 beta.
Any help would be very appreciated :pray: :slight_smile:


import bpy
import math 

r = math.radians(45)
mycube = bpy.data.objects['Cube']
mycube.rotation_euler = (0,r,0)
    
print("start")

def my_handler(scene):
    print("Frame Change", scene.frame_current)
    r += math.radians(5)
    
    mycube.rotation_euler = (0,r,0)
    bpy.context.view_layer.update()

bpy.app.handlers.frame_change_pre.append(my_handler)