-2
from notifypy import Notify
import schedule

def remember_water():
    notification = Notify()
    notification.title = "XXX"
    notification.message = "XXX"
    notification.send()


schedule.every().hour.do(remember_water())
while True:
    schedule.run_pending()
    time.sleep(1)

Tried to make a notification to drink water every hour... getting a type error when execute, maybe there are some other modules that are better. Did´nt get in touch with these modules ever, pls help :)

1 Answers1

3

Running your code produces:

Traceback (most recent call last):
  File "/home/lars/tmp/python/drink.py", line 11, in <module>
    schedule.every().hour.do(remember_water())
  File "/home/lars/.local/share/virtualenvs/lars-rUjSNCQn/lib/python3.10/site-packages/schedule/__init__.py", line 625, in do
    self.job_func = functools.partial(job_func, *args, **kwargs)
TypeError: the first argument must be callable

Your problem is here:

schedule.every().hour.do(remember_water())

The argument to the .do method must be a callable (like a function), but you are calling your function here and passing the result. You want to pass the function itself:

schedule.every().hour.do(remember_water)
larsks
  • 277,717
  • 41
  • 399
  • 399