Search code examples
pythonpythonanywhere

Scheduled task at pythonanywhere.com with TypeError


i have a python script on pythonanywhere.com and want to run it daily in a scheduled task. If i run the script manually everything works great.

Unfortunately this is not possible in a task - when the script starts it shows following error message:

Traceback (most recent call last): maxprice = re.search('priceto='+r"[0-9]{4,8}",string)[0]

TypeError: '_sre.SRE_Match' object has no attribute 'getitem'

2018-04-05 13:09:09 -- Completed task, took 5.00 seconds, return code was 1.

Is there anything special to do, when i want to start a scheduled job on pythonanywhere.com?

Sample script:

import re

string = 'priceto=10750&&type=B'

maxprice = re.search('priceto='+r"[0-9]{4,8}",string)[0]
print(maxprice)

Solution

  • I found a solution for the problem... it is necessary to add the python version to the scheduled task setup.

    Instead of:

    /home/User/Folder/Sample.py

    Use:

    python3.6 /home/User/Folder/Sample.py