Python CronTab(user=name)失败,TypeError:uuu init_uuuuuuuuuu()获得意外的关键字参数';用户';
我通过“cron”尝试了这个脚本,但它向我显示了这样一个错误Python CronTab(user=name)失败,TypeError:uuu init_uuuuuuuuuu()获得意外的关键字参数';用户';,python,linux,automation,cron,python-3.6,Python,Linux,Automation,Cron,Python 3.6,我通过“cron”尝试了这个脚本,但它向我显示了这样一个错误 从crontab导入crontab my_cron=CronTab(user='arpit') job=my_cron.new(command='/home/hirensoni/Documents/arbit/scassing.py') 作业。分钟。每(1) 我的克朗。写() 错误: 发生异常:TypeError __init_;()获得意外的关键字参数“user” 文件“/home/hirensoni/Documents/arbi
从crontab导入crontab
my_cron=CronTab(user='arpit')
job=my_cron.new(command='/home/hirensoni/Documents/arbit/scassing.py')
作业。分钟。每(1)
我的克朗。写()
错误:
发生异常:TypeError
__init_;()获得意外的关键字参数“user”
文件“/home/hirensoni/Documents/arbit/regular automation.py”,第3行,在
my_cron=CronTab(user='arpit')
我想您已经安装了而不是。这两个库共享同一名称空间
要解决此问题,可以替换库:
pip uninstall crontab
pip install python-crontab
编辑
此外,请使用您的真实用户名
您的报废.py
脚本必须是可执行的。最好使用真正的命令,例如/usr/local/bin/python\u script.py
from crontab import CronTab
my_cron = CronTab(user='hirensoni')
job = my_cron.new(command='/usr/local/bin/python /home/hirensoni/Documents/arpit/scrapping.py')
job.minute.every(1)
my_cron.write()
现在,它引发了一个新的错误,如:文件“/home/hirensoni/.local/lib/python3.6/site packages/crontab.py”,第295行,在read raise IOError(“read crontab%s:%s”%(self.user,err))OSError:read crontab arbit:b“crontab:user`arbit'unknown\n”@LaurentIf如果它解决了您的问题,您可以接受这个答案。第二个问题是另一个问题:最好发布一个新问题。好的,谢谢@Laurent@arpit_25“arpit”不是你的用户名,不是吗?是“海伦索尼”?如果“arpit”是同一台计算机上的另一个用户,则您可能没有正确的访问权限和/或凭据。“arpit”是/home/hirensoni/Documents/arpit@Laurent下的文件夹名