Flask application does not compile when I put the pywhatkit library inside

Question:

I have an application in flask and I tried to insert within that application a code to automatically send messages to whatssap.

  • Code:
import pywhatkit as pwk
import time


def whats():
    tim = time.localtime()

    hour = int(time.strftime("%H", tim))
    min = int(time.strftime("%M", tim))

    if min==59:
        min = 0
    else:
        min += 1
    # using Exception Handling to avoid unexpected errors
    try:
          # sending message in Whatsapp in India so using Indian dial code (+91)
          pwk.sendwhatmsg("+5587988758805", "Trabalhador sem EPI!", hour, min)
          print("Message Sent!") #Prints success message in console
    # error message
    except: 
        print("Error in sending the message")

Both codes are working perfectly, but when I put the two codes together the code doesn’t compile.

I did some tests:

  1. I tried to just import pywhatkit as pwk in the flask application;

  2. I tried to use the code in another python file and import;

  3. I tried to put both codes together in same python file.

In all situations the code does not compile, when I debug the code for test 1, I get the following error:

Exception has occurred: SystemExit 3
  File "C:UsersdiegocodesWorkingmodify.py", line 96, in <module>
    app.run(debug=True)

Why can’t I compile my code when I put the pywhatkit library inside the flask application?

Asked By: Diego A

||

Answers:

For all of you who have a similar problem, I was able to solve it by installing pywhatkit version 5.0.

Answered By: Diego A
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.