-2

Hello i am your assistant and i am gonna remind you periodically to have a break or do exercise or to drink water

Traceback (most recent call last):
  File "C:\Users\lenovo\.spyder-py3\python_project_exercise7.py", line 51, in <module>
    schedule.every(10).minutes.do(waater())

AttributeError: 'Job' object has no attribute 'do'
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 29 15:14:04 2021

@author: Asrar
"""
import schedule
import time
import datetime
from datetime import *
    
def waater():
    print('hehe')

schedule.every(10).minutes.do(waater())

and the output is like this:

1

Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
Asrar
  • 21
  • 5
  • Hmm, [`Job.do`](https://schedule.readthedocs.io/en/stable/reference.html?highlight=Job#schedule.Job.do) is clearly present in the docs, and AFAICT that method has not changed since the `schedule` package was first created. You might try `print(schedule.__file__)` and see if there is anything funky with your local copy of the file. – 0x5453 Sep 29 '21 at 15:24
  • Also, try deleting & retyping the characters `.do(` - maybe there's some invisible character in there, or one of the letters is actually some different character (from Cyrillic, perhaps) that just looks like a 'd' or an 'o'. – jasonharper Sep 29 '21 at 15:28
  • 2
    The traceback says _line 51_, but you provided only the code from the lines 1-35. – Sven Eberth Sep 29 '21 at 15:33
  • The first error that we can see in your screenshot is the important one: `TypeError: the first argument must be callable`. The second error that you've posted is a red herring. – 0x5453 Sep 29 '21 at 15:47

2 Answers2

2

Schedule should call the method for you, so you only have to pass the method without the parentheses as the argument for do().

schedule.every(10).minutes.do(waater)
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
  • 2
    How does this answer the question? You're still calling `.do()`, which the error says doesn't exist... – John Gordon Sep 29 '21 at 15:20
  • Hmm. In the lower-right area of the screenshot I see that a function named `do()` is actually being executed, which is confusing. – John Gordon Sep 29 '21 at 15:30
  • 1
    @JohnGordon indeed this does not solve the error quoted in the question, but the one in the code. But then the question also lacks information. The line-no from the traceback does not match the code in the screenshot and otherwise the code looks ok so far. – Sven Eberth Sep 29 '21 at 15:31
  • @JohnGordon Ahh, we can see from OP's screenshot that the *actual* error is: `TypeError: the first argument must be callable` – 0x5453 Sep 29 '21 at 15:46
  • @0x5453 Yeah. I have no idea how the callable error would lead to the attribute error. – John Gordon Sep 29 '21 at 16:05
0

You only have to refer to your function as an object (waater), not call upon it (waater()).

  • @Sven Eberth I tried to run that code(waater without parenthesis) also but still isn't working. I think the fate is messing with me – Asrar Sep 30 '21 at 02:44
  • Hey guys it is done now, I had to uninstall my anaconda n spyder(ide)than again install it and I had to download the schedule module through conda instead pip .so anyone else facing the same problem could use this same technique or whatever I am just happy that I can code now. Look first uninstall and reinstall your anaconda(that will automatically uninstall spyder idea) and after successfully installed your ide again go to Google type there first conda and than the package or module and that will give it's download code or the line of code that you have to put in your terminal and success – Asrar Sep 30 '21 at 06:48