我试图通过使用runipy和osx的launchd定期运行一个jupyter笔记本。
这在命令行中起作用。
/path/to/interpreter/python.3.4 /path/to/runipy/main.py /path/to/notebook/nb.ipynb但是,在launchd plist中,类似的方法无法启动笔记本。
<key>ProgramArguments</key>
<array>
<string/path/to/interpreter/python.3.4</string>
<string/path/to/runipy/main.py</string>
<string/path/to/notebook/nb.ipynb</string>
</array>当我检查控制台日志时,我只看到这个神秘的错误。
Service exited with abnormal code: 1对为什么失败有什么想法吗?
注意:我目前正在使用launchd使用类似的方法在这台机器上运行py文件。
更新:
根据wij的建议,我在我的plist中添加了以下几行
<key>StandardErrorPath</key>
<string>/tmp/com.your.thing.err</string>
<key>StandardOutPath</key>
<string>/tmp/com.your.thing.out</string>并得到了
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3940: ordinal not in range(128)发布于 2016-03-16 13:42:14
通过创建一个使用runipy的中介py文件,并使用encoding="utf-8“打开笔记本,我克服了"ascii”错误。
nb_launcher.py
from runipy.notebook_runner import NotebookRunner
from IPython.nbformat.current import read
notebook = read(open("nb.ipynb", encoding="utf-8"), 4)
r = NotebookRunner(notebook)
r.run_notebook()从launchd上打电话
<key>ProgramArguments</key>
<array>
<string/path/to/interpreter/python.3.4</string>
<string/path/to/py_file/nb_launcher.py</string>
</array>发布于 2016-03-14 22:06:22
你在用LaunchControl吗?我建议您使用它来轻松捕获控制台中的标准错误,并查看底层异常代码1。如果没有LaunchControl,您还可以将这些键添加到.plist中:
<key>StandardErrorPath</key>
<string>/tmp/com.your.thing.err</string>
<key>StandardOutPath</key>
<string>/tmp/com.your.thing.out</string>https://stackoverflow.com/questions/35928118
复制相似问题