Forums

Script raises and error in Scheduler but not when I run manually

This is a very simple code

that is designed to scrap the Super 6 website for a date and then push a message to my phone if the time is within 12 hours.

It works perfectly fine when I run it manually from the pythonanywhere servers. It works fine when the time is over 12 hours away. But once it runs via the scheduler and calls the send message function it runs into an error.

The log reads:

Traceback (most recent call last):
  File "/home/spacedlevo/super6/scrap_super6.py", line 71, in <module>
    pushover_notification(msg)
  File "/home/spacedlevo/super6/scrap_super6.py", line 20, in pushover_notification
    urllib.parse.urlencode({
AttributeError: 'module' object has no attribute 'parse'

2017-08-26 10:01:31 -- Completed task, took 35.00 seconds, return code was 1

When you schedule it, are you specifying the Python version to use? That is, is the command that you entered into the scheduler something like this:

/path/to/your/script.py

or

python3.5 /path/to/your/script.py

...? The latter will make sure it's run with Python 3.5 (of course, if you want a different version of Python 3, then you can specify that).

I have just given the path to the file and no python version.

When I look in my consoles it looks like python 3.5 has run the program by default and all the tests that I have run before the scheduling have been using python3+

EDIT: Tested out specifying the python type to 3.6 and this has worked, thanks

Excellent, glad it worked. For the previous scripts, perhaps you had a hashbang at the start, for example:

1
#!/usr/bin/python3.5

...?