It’s not be something that too many people here will ever need to do, but nonetheless…
When Panorama runs a Python script, it creates a temporary Python file. The name begins with pan. plus the date in a dot format: 2023.10.23, plus the time in a dot format that is hard to precisely target and finally ends with .py. The name ends up something like this: pan.2023.10.12.12.19.42.650.py.
That python file is saved inside a folder nested within /private/var/folders/xxxx/T. The xxxx represents some folders that change from time to time but there are few of them so it’s not hard to find the T folder.
If the script runs successfully the file is immediately deleted. But if there’s an error the file remains behind, and that is the point of all of this.
The Python file can be opened in BBEdit and you can look at any problem line noted by Panorama’s error message or any other lines to see if there’s an obvious issue. You can try various solutions to debug it and have BBEdit run the script for you via Run/R in the #! menu. BBEdit creates a detailed Unix Script Output Log that shows the result.
Sometimes it turns out to be easy to recognize or find and correct the issue. But this method certainly beats trying to run it over and over in Panorama when trying to fix a Python issue.