0

I'm using a python script to update crontab for a particular user 'pi' using code below and keep getting this error. Using this same exact script on a ubuntu works without any error. Anyone got any ideas why this might be?

CODE:

***my_cron = CronTab(user='pi')
            for job in my_cron:
            if job.comment == i:
                job.minute.on(crminutes)
                job.hour.on(crhour)
                my_cron.write()***

ERROR:

***Traceback (most recent call last):
  File "crontimings.py", line 455, in <module>
    my_cron = CronTab(user="pi")
TypeError: __init__() got an unexpected keyword argument 'user'***

Script permission look like this:

-rwxr-xr-x 1 pi pi 16686 Apr 24 19:34 crontimings.py

Raheel R
  • 19
  • 4

1 Answers1

2

I think you have the wrong library installed. You should do pip install python-crontab, not pip install crontab.

See https://pypi.org/project/python-crontab/

kimbo
  • 2,513
  • 1
  • 15
  • 24
  • That's what I have installed. Driving me nuts same thing works on one system and not on the other. Not sure what i'm missing. – Raheel R Apr 25 '20 at 16:07
  • hmm that's weird. Make sure the other one is uninstalled (`pip uninstall crontab`). Also, you could try looking at the function signature. See this answer https://stackoverflow.com/a/2677263/9638991 – kimbo Apr 25 '20 at 17:09
  • 1
    funny thing happened...three years later ran into same issues and quick search gave me the this post of mine as the first result. Didn't even notice it until few minutes later that it was I who had asked this question before :D – Raheel R Jan 05 '23 at 00:24