1

So I have the following script which I am using to grab data from the net and save it as an html file in a folder on my pc (same pc) each time I run the script. I'm now trying to automate the process.

import pandas as pd
import datetime as dt
today_date = dt.date.today().isoformat()
df = pd.read_html('http://www.livevol.com/largest-option-trades-on-the-day', header=1)[0].set_index('Time')
html_name = 'option data/{}.html'.format(today_date)
df.to_html(html_name)

Ordinarily, when I click on the .py, I get a the black screen (command prompt) which lasts for a few seconds and then If I go to a certain folder, I see that a new html has been created.

However, when I use Windows scheduler, the script seems to run but an html file is not being created.

The script seems to be running because the command prompt black screen pops up and stays there for a few seconds (rather than just flashing), just like it did when I manually clicked on the .py file.

I've played around with the different parameters of the "actions" field of Windows Scheduler.

Program/script: C:\Python27\python.exe Add arguments: C:\Python27\Option.py

"Run when user is logged on" and "highest privileges" are check-marked.

Not sure what I'm doing wrong. Thanks.

GreenMatt
  • 18,244
  • 7
  • 53
  • 79
Moondra
  • 4,399
  • 9
  • 46
  • 104
  • Admittedly, I'm no Windows guru, but are you sure the program has permission to write to that directory when run from the Windows Scheduler? – GreenMatt Sep 30 '16 at 16:00
  • I'm running as the administrator so I think it should. I'm going to try reinstalling Python2.7 as I have been having this odd bug, where a different script runs in addition to the script I want to run. Essentially, one script has been somehow imprinted into Python so that whenever I run any script, the imprinted script first get ran, and then the script I chose will get ran. Weird bug, and maybe that's what Is confusing Windows Scheduler. – Moondra Sep 30 '16 at 17:55
  • So I reinstalled Python2.7 but still can't get Windows Scheduler to run that file. I'm wondering if it is indeed some permission problem. I'm going to Google it see what I come up with. – Moondra Sep 30 '16 at 18:27
  • Have a look at my answer in here: https://stackoverflow.com/questions/54847871/launching-python-script-from-windows-command-line-script-starts-then-fails/56854018#56854018 Cheers – Jonathan Mallia Jul 02 '19 at 14:04

2 Answers2

0

I got it working by filling in the "Start in(optional)" parameter under the Actions tab, with the first part of the path to the Python exe.

"C:\Python27"

Moondra
  • 4,399
  • 9
  • 46
  • 104
0

this worked for me:

set up a conda environment: Schedule a Python script via batch on windows (using Anaconda)

if you need a proxy: Running conda with proxy

REdim.Learning
  • 655
  • 2
  • 14
  • 32