I am writing a cgi script to run on a server, and when I put #!/bin/python3 at the top of the file it works fine. The problem is that on my local machine, my Python installation is in /opt/local/bin/python (and macOS does not allow symlinks in /bin. So to run the script on my local machine, I need to manually change the path in each cgi file, which is cumbersome.
Is there a better way to specify my Python path (something like "try this path first else try this path?")
You can let your system environment choose the path using #!/usr/bin/env python3
Specify Python location in cgi script