For Linux:
Goto > Build > Set Build Commands
In the Python Commands Edit the Command text box as:
python3 -m py_compile "%f"
In the Execute Commands Edit the Command as:
python3 "%f"

In the same way You can configure Geany for Python2 simply remove the '3' as:
In the Python Commands Edit the Command text box as:
python -m py_compile "%f"
In the Execute Commands Edit the Command as:
python "%f"
You can also configure for specific python versions like Python3.7 simply replace the version number in the Set Build Commmands like:
python3.7 -m py_compile "%f"
in Commands and python3.7 "%f"
in Execute
For Windows:
Goto > Build > Set Build Commands
In the Python Commands Edit the Command text box as:
python -m py_compile "%f"
In the Execute Commands Edit the Command as(If you are using python3.7 and python is installed in C drive, otherwise browse to where Python is installed and replace it with the path, if path variable is not set):
C:\Python37\python "%f"
If you have python set in path variable, then this will work:
python "%f"