[英]Python Scikit learn script crashing in Windows Task Scheduler
I have a python script using Scikit-learn libraries and it works completely fine when I run it manually in either Jupyter notebook or command line.我有一个使用 Scikit-learn 库的 python 脚本,当我在 Jupyter 笔记本或命令行中手动运行它时,它工作得很好。 However, it doesn't work when I schedule it in Windows Task Scheduler.但是,当我在 Windows 任务计划程序中安排它时,它不起作用。 After spending a lot of time I realised the issue is due to the sklearn
imports.花了很多时间后,我意识到问题是由于sklearn
导入造成的。 If I comment out the sklearn imports, the script works fine in the scheduler but the moment I include a sklearn import, the scheduler doesn't execute one line of the script.如果我注释掉 sklearn 导入,则脚本在调度程序中工作正常,但是当我包含 sklearn 导入时,调度程序不会执行脚本的一行。 I have no idea what is causing this and it's even more surprising that the script works like a charm when running it manually.我不知道是什么原因造成的,更令人惊讶的是,脚本在手动运行时就像一个魅力。 I've uninstalled and reinstalled Anaconda distribution on my PC but no result.我已经在我的 PC 上卸载并重新安装了 Anaconda 发行版,但没有结果。 Any help on how I can fix this please?请帮助我解决这个问题吗?
I finally managed to fix this.我终于设法解决了这个问题。 Turns out it's a corrupted scipy
package.原来它是损坏的scipy
package。 Uninstalling and re-installing it fixed the issue.卸载并重新安装它解决了这个问题。
The way I figured it out is by running my python script as a batch file which threw the following error我想出来的方法是将我的 python 脚本作为批处理文件运行,这会引发以下错误
from scipy.sparse.linalg import lsqr as sparse_lsqr从 scipy.sparse.linalg 导入 lsqr 作为 sparse_lsqr
ImportError: DLL load failed: The specified module could not be found. ImportError: DLL 加载失败:找不到指定的模块。
I never got this error when I ran my python script from the windows scheduler or Jupyter notebook or even command line, which is very strange.当我从 windows 调度程序或 Jupyter 笔记本甚至命令行运行我的 python 脚本时,我从未收到此错误,这很奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.