That’s not how it works. See this extensive info by @Helvetosaur:
Running Python scripts from aliases or toolbar buttons