Thanks for taking the time to reply. The script isn’t intended to be run from the command line, so I expect you would always get an error trying to run it as a standalone script.
The error was actually a database permission issue. This was throwing a python error, which I was trying to catch and route to the Apache error log via writing to stderr. I understood that by default, anything written to stderr would be included in the Apache error log. This works on my Mint testing box, but doesn’t seem to work on the Site5 server.