[英]Intermediate bash output in Jupyter notebook
When I run this in terminal:当我在终端中运行它时:
cd 1st_flask_app_1/
python3 app.py
I get the output:我得到输出:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
When I try to run the same command in a Jupyter notebook with the cell magic %%bash
, I get no printed output, but the web app still starts up and I can visit it.当我尝试在带有单元魔法
%%bash
的 Jupyter 笔记本中运行相同的命令时,我没有打印输出,但 Web 应用程序仍然启动并且我可以访问它。 If I then stop the cell I get the output:如果我然后停止单元格,我会得到输出:
Process is interrupted.
So it looks like the Jupyter notebook with %%bash
cell magic is printing final command outputs, but not intermediate outputs.所以看起来带有
%%bash
cell magic 的 Jupyter notebook 正在打印最终命令输出,而不是中间输出。 Is there any way to also print the intermediate outputs?有什么办法也可以打印中间输出吗?
For some reason it looks like your stdout
/ stderr
are not properly attached to your bash...出于某种原因,您的
stdout
/ stderr
似乎没有正确附加到您的 bash 上...
Could you try to redirect your command stdout
and stderr
to a log file in append mode?您可以尝试在追加模式下将命令
stdout
和stderr
重定向到日志文件吗?
python3 app.py >> application.log 2>&1
or you could also pipe it with tee
或者你也可以用
tee
管
python3 app.py 2>&1 | tee -a application.log
I hope this helps you!我希望这可以帮助你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.