Serial port work only with serial monitor

Hello everyone. This is my code on pyton:

import serial, sys
# Set up serial port
try:
  ser = serial.Serial("/dev/tty.usbserial-A700eRV8", 9600)
except serial.SerialException:
     sys.exit()
ser.write('M')
ser.close()

Arduino should turn LED on, if we have 'M'. It works, but strange: if I open Serial Monitor in Arduino IDE, and run my script, it works. If I close Serial Monitor, script doesn't work (led is just turn on fast for short time once).

What is the reason of this issue? How can I resolve this?

Thanks for help!

Disable the board’s auto reset

Thank you very much! I resolved issue.

ser = serial.Serial("/dev/tty.usbserial-A700eRV8", 9600)
ser.setDTR(False)
time.sleep(1.5)

Just add ser.setDTR(False) was insufficiently. I found a recommendation to add timer sleep for 0.5 sec. It did't work also. I changed time to 1.5 and now it works!