繁体   English   中英

从启动运行runipy

[英]Running runipy from launchd

我试图通过利用runipy和osx的启动来定期运行jupyter笔记本。

从命令行工作

/path/to/interpreter/python.3.4 /path/to/runipy/main.py /path/to/notebook/nb.ipynb

但是启动的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的建议在我的列表中添加了以下几行

<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)

您正在使用LaunchControl吗? 我建议您使用它,以便您可以轻松地在控制台中捕获“标准错误”并查看潜在的异常代码1。如果没有LaunchControl,还可以将这些键添加到.plist中:

<key>StandardErrorPath</key>
<string>/tmp/com.your.thing.err</string>
<key>StandardOutPath</key>
<string>/tmp/com.your.thing.out</string>

我通过创建一个使用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()

并从启动调用

<key>ProgramArguments</key>
<array>
    <string/path/to/interpreter/python.3.4</string>
    <string/path/to/py_file/nb_launcher.py</string>
</array>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM