1

It works with test.py showing simple print statement

BUT not working for below code, how to have this below code executed through scheduler

import pywhatkit

pywhatkit.sendwhatmsg('+91xxxxxxxxx', 'Good Morning', 18, 18)
Kat
  • 23
  • 4
  • Is this working outside of task scheduler? – Axe319 Jun 10 '21 at 13:08
  • yes it is working. I can execute this from Spyder console, which opens browser (whatsapp) and send the message – Kat Jun 10 '21 at 13:12
  • This is most likely related to how the task is set up. `Run only when user is logged on` probably needs to be checked. `Program/script` should be the path to the python executable. `add arguments` should be your python script and `Start in` should be the path your folder resides in. – Axe319 Jun 10 '21 at 13:15
  • I have all this option checked. I can run my another program (game) through task scheduler but not this 2 line code program. It opens and in split second action started and says action completed. Not sure external browser that it has to open is the issue.. – Kat Jun 10 '21 at 13:21
  • You could run it with the `-i` option. So, `-i my_script.py`. This will leave the interpreter open after an error in your script occurs or your program ends to help you debug. Either that or have it dump the logging to a file somewhere. – Axe319 Jun 10 '21 at 13:29
  • "-i stest.py" - This makes my error count 0*2 – Kat Jun 10 '21 at 13:49
  • it is giving error for programs referencing files outside and if it happens to open a browser. Other programs just with for loops and print statement working fine – Kat Jun 10 '21 at 13:54
  • Out of curiosity can you run this from command line? – Axe319 Jun 10 '21 at 14:04
  • how to run from command prompt? when running should I be in the path where program resides when running – Kat Jun 10 '21 at 14:13
  • Yes. The command should be `"Path\to\python.exe" "my_script.py"`. Where `Path\to\python.exe` is the path to your python executable. – Axe319 Jun 10 '21 at 14:15

0 Answers0