Command line switch command failed

this is my configuration

switch gate:
   platform: command_line
   switches:
    gate:
      command_on: 'python /home/homeassistant/switch_script/gate.py'
      command_off: 'false'

please help me! i tried everything i found here but nothing works!! i always get the same error command failed.
please help!!

Try running the same command from the shell. Sudo (become) the user that your HA install runs as (hass or ha, etc, depending on your install). Be sure to source the virtual environment if your install uses one. Then run as HA inside the vitrual environment. That’ll rule out permissions and

i already did all of that! the commands work perfectly in the terminal on the homeassistant user! It is unrelated to the command!the problem is in home assistant because even the simplest commands don’t work like ls,cd…

Post your YAML (using preformatted text).

Does a shell_command work for you with the same script payload?

well thank you! i ll try that and see what happens

well it didn’t give me any errors