如何通过 Windows Scheduler 运行 宁 python 文件输出 plotly plot 运行 批处理文件

How to run batch file through Windows Scheduler running python file outputting plotly plot

我有一个批处理文件,它运行 python 文件,通过 Plotly 在 html 文件中输出交互式绘图。 运行 通过双击运行文件很好,但是当 运行 通过 Windows 调度程序时,它不起作用。

Python 代码生成情节 html:

plot(fig,filename='output.html')

批处理文件运行python文件:

python file.py

双击批处理文件有效。 运行 通过 Window 的调度程序的批处理文件不起作用,并在命令提示符中输出以下错误:

Traceback (most recent call last):
   File "C:\~\file.py", line 224, in <module> plot(fig,filename='output.html')
   File "C:\ProgramData\Anaconda3\lib\site-packages\plotly\offline\offline.py", line 721, in plot with open(filename, 'w') as f:
PermissionError: [Errno 13] Permission denied: 'output.html'

知道为什么这不能通过 Windows 调度程序工作吗?

想通了。

我没有将任务计划程序中的任务设置为 "Run with highest privileges."选中该框解决了问题。