According to Apache documentation
The ScriptAlias directive has the same behavior as the Alias
directive, except that in addition it marks the target directory as
containing CGI scripts that will be processed by mod_cgi's cgi-script
handler. URLs with a case-sensitive (%-decoded) path beginning with
URL-path will be mapped to scripts beginning with the second argument,
which is a full pathname in the local filesystem.
The ScriptAlias directive looks like:
ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
It means that if you Request URL http://mydomain/cgi-bin/myscript.py
Apache tries to run /usr/local/apache2/cgi-bin/myscript.py
The ScriptAlias directive tells Apache that a particular directory is
set aside for CGI programs. Apache will assume that every file in this
directory is a CGI program, and will attempt to execute it, when that
particular resource is requested by a client.
ScriptAlias directive is in default apache2.conf
configuration file and it works if mod_cgi is enabled and myscript.py
is executable and return proper output.
If you have a different configuration, you should read: Apache Tutorial: Dynamic Content with CGI