Jupyter笔记本不会将日志打印到输出单元格 [英] Jupyter notebook does not print logs to the output cell

查看:1175
本文介绍了Jupyter笔记本不会将日志打印到输出单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Jupyter 笔记本,我想强制它将 Python 日志打印到输出我正在使用过去以这种方式工作的旧笔记本,可能是旧版本的 Jupyter 笔记本。



我的日志记录设置为:

  import logging 
logging.basicConfig(format ='%(levelname)s:%(message)s',level = logging.INFO)
logging.root.level = 20

但是当我打电话时:

  logging.info (hello world)

它不会在输出单元格中打印任何内容。它只打印出控制台中的东西,我在其中启动了 Jupyter 笔记本。



我正在使用 python 2.7.10 我的虚拟环境中安装的软件包是:

  appnope = = 0.1.0 
backports-abc == 0.4
backports.ssl-match-hostname == 3.5.0.1
certifi == 2016.2.28
decorator == 4.0.9
functools32 == 3.2.3.post2
gnureadline == 6.3.3
ipykernel == 4.3.1
ipython == 4.1.2
ipython-genutils = = 0.1.0
ipywidgets == 4.1.1
Jinja2 == 2.8
jsonschema == 2.5.1
jupyter == 1.0.0
jupyter-client = = 4.2.2
jupyter-console == 4.1.1
jupyter-core == 4.1.0
MarkupSafe == 0.23
mistune == 0.7.2
nbconvert == 4.1.0
nbformat == 4.0.1
notebook == 4.1.0
path.py == 8.1.2
pexpect == 4.0.1
pickleshare == 0.6
ptyprocess == 0.5.1
Pygments == 2.1.3
pyzmq == 15.2.0
qtconsole == 4.2.0
simplegeneric == 0.8.1
singledispatch == 3.4.0.3
six == 1.10.0
terminado == 0.6
龙卷风== 4.3
traitlets == 4.1.0
wheel == 0.24.0

是否更改了单元格中的打印输出?有什么方法可以强制 Jupyter 写出输出单元格的日志记录?

解决方案

我找到了一个旧的 python 2.7.10 virtualenv其中 jupyter 按需运作。

  appnope == 0.1.0 
backports.ssl-match-hostname == 3.4.0.2
boto == 2.38.0
bz2file == 0.98
certifi == 2015.9.6.2
decorator == 4.0 .4
functools32 == 3.2.3.post2
gensim == 0.12.2
gnureadline == 6.3.3
httpretty == 0.8.6
ipykernel = = 4.1.1
ipython == 4.0.0
ipython-genutils == 0.1.0
ipywidgets == 4.1.1
Jinja2 == 2.8
jsonschema = = 2.5.1
jupyter == 1.0.0
jupyter-client == 4.1.1
jupyter-console == 4.0.3
jupyter-core == 4.0.6
MarkupSafe == 0.23
mistune == 0.7.1
nbconvert == 4.1.0
nbformat == 4.0.1
notebook == 4.0.6
numpy == 1.10.1
path.py == 8.1.2
模式== 2.6
pexpect == 4.0.1
pickleshare == 0.5
ptyprocess == 0.5
Pygments == 2.0.2
pyzmq == 14.7.0
qtconsole == 4.1.0
requests == 2.8.1
scipy = = 0.16.0
simplege neric == 0.8.1
six == 1.10.0
smart-open == 1.3.0
terminado == 0.5
tornado == 4.2.1
traitlets == 4.0.0
wheel == 0.24.0

有些套餐不相关使用 jupyter 问题,问题可能出现在某些相关软件包的版本中。我会尝试进一步调查确切的位置。



编辑:



在结束我发现问题出在包中: ipykernel == 4.3.1 或者自 ipykernel == 4.3.0 一切正常, ipykernel == 4.1.1 ipykernel == 4.2.2



github向jupyter和ipykernel报告了问题: https ://github.com/ipython/ipykernel/issues/111


I am currently using Jupyter notebook and I would like to force it to print out Python logs to the output cell.

I am using old notebook that used to work this way, probably in older version of Jupyter notebook.

I have logging set as:

import logging
logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.INFO)
logging.root.level = 20

But when I then call:

logging.info("hello world")

It does not print anything in the output cell. It just prints out the stuff in the console in which I started the Jupyter notebook.

I am using python 2.7.10 and installed packages in my virtual environment are:

appnope==0.1.0
backports-abc==0.4
backports.ssl-match-hostname==3.5.0.1
certifi==2016.2.28
decorator==4.0.9
functools32==3.2.3.post2
gnureadline==6.3.3
ipykernel==4.3.1
ipython==4.1.2
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.2.2
jupyter-console==4.1.1
jupyter-core==4.1.0
MarkupSafe==0.23
mistune==0.7.2
nbconvert==4.1.0
nbformat==4.0.1
notebook==4.1.0
path.py==8.1.2
pexpect==4.0.1
pickleshare==0.6
ptyprocess==0.5.1
Pygments==2.1.3
pyzmq==15.2.0
qtconsole==4.2.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
terminado==0.6
tornado==4.3
traitlets==4.1.0
wheel==0.24.0

Was logging printout in the cell changed? Is there some way how I can force Jupyter to write out logging to the output cell?

解决方案

I have found one my old python 2.7.10 virtualenv where jupyter works as desired.

appnope==0.1.0
backports.ssl-match-hostname==3.4.0.2
boto==2.38.0
bz2file==0.98
certifi==2015.9.6.2
decorator==4.0.4
functools32==3.2.3.post2
gensim==0.12.2
gnureadline==6.3.3
httpretty==0.8.6
ipykernel==4.1.1
ipython==4.0.0
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.1.1
jupyter-console==4.0.3
jupyter-core==4.0.6
MarkupSafe==0.23
mistune==0.7.1
nbconvert==4.1.0
nbformat==4.0.1
notebook==4.0.6
numpy==1.10.1
path.py==8.1.2
Pattern==2.6
pexpect==4.0.1
pickleshare==0.5
ptyprocess==0.5
Pygments==2.0.2
pyzmq==14.7.0
qtconsole==4.1.0
requests==2.8.1
scipy==0.16.0
simplegeneric==0.8.1
six==1.10.0
smart-open==1.3.0
terminado==0.5
tornado==4.2.1
traitlets==4.0.0
wheel==0.24.0

Some packages are not related with the jupyter problem here, problem will probably be in versions of some relevant packages. I'll try further investigate exactly where.

EDIT:

At the end I have found that the problem is in the package: ipykernel==4.3.1 or since ipykernel==4.3.0 everything works fine with ipykernel==4.1.1 or ipykernel==4.2.2.

Issue was reported at github to the jupyter and ipykernel: https://github.com/ipython/ipykernel/issues/111

这篇关于Jupyter笔记本不会将日志打印到输出单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆