As far as I know, Geany by default uses Python 3 to run the Python codes. So in order to run Python 2 codes, do the following.
Step 1: Go to Build -> Set build commands in the menu bar (screenshot attached below).
Build -> Set Build Commands
Step 2: You would get a "Set Build Commands" window like this:
Set Build Commands window
You can clearly see the "Compile" and "Execute" build commands as python3 -m py_compile "%f" and python3 "%f" respectively.
Step 3: In both of these commands, change python3 to python and you are good to go. Doing this directs Geany to call python instead of python3:
New Build Commands
And make sure before doing all these, save the code with a .py extension!