I followed this tutorial for changing the background on my macOS Monterey 12.5. When I run the Python script my background ist not changing but I also don't get an error message.
In System Preferences > Security & Privacy > Automation
I added the terminal in which I execute the script for being able to access Finder
.
Code to change background:
cmd = "osascript -e 'tell application \"Finder\" to set desktop picture to POSIX file \"" + filename + "\"'"
os.system(cmd)