applescript inside python not working after monterey update

I have the following code inside a python file:

   applescript.run('''

            tell application "System Events"

                -- one second delay
                delay 1
                -- to press command+shift+g
                keystroke "G" using {command down, shift down}
                
                delay 2
                -- to enter file path
                keystroke "/Users/xxx/Documents/web_images/image_1.jpg"
                delay 1
                
                -- hit return twice
                keystroke return
                delay 1
                keystroke return

            end tell
            
    ''')

It was working great until I installed Monterey, now it's not working anymore. Anyone any idea how to fix it?

Solved it, ran a similar script from the script editor and had to give permission again for something, now it's working from inside python again as well.

applescript inside python not working after monterey update
 
 
Q