Forums

Running scheduled task with different python version

Hi, I have a code which needs python3 to work properly and it seems like by default scheduled task runs the module using python2 and hence it throws error.

How can i make it run using python3?

EDIT: So i managed to get it running by explicity using python3.4 /path/to/file But now there's another problem. I am using sqlite3 and it keeps on saying that table "mytable" doesn't exist. Should I need to provide absolute pathname to the sqlite file?

Yes: you need to give an absolute path to your sqlite file, or you need to set the current working directory to the one where the sqlite file lives.

I have a very similar situation and the sqlite DB is in the same directory as the script and It won't write to the DB file.

It works fine in the console, but not in the scheduler.

Did you use an absolute path? Or a relative path? This is probably because you first navigated to the directory that the script is in when you ran it in the console.

I assumed that since my script was in the same directory as the DB file, the script was already set to the "current working directory"

I set it to read from the absolute path i.e. /home/username/appname/database.db and now it works perfectly.

Thanks for the help! It is great to be able to get help, even with these simple things.