Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Import issue: AttributeError: 'NoneType' object has no attribute 'session'

未关闭
#552 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
jupyter, python
领域
tooling

调研方向

先从 ipykernel/comm/comm.py 和 matplotlib/backends/backend_nbagg.py 中的 traceback 路径入手,然后从 VS Code 重现 cerebro.plot()。将该执行上下文与 issue 中描述的 Jupyter 相关行为进行比较。Done 应意味着已重现该故障,并且该故障已修复,或已明确记录受支持的执行上下文。

由索引模型根据 Issue 内容生成。

描述

When import the package inside VScode I get an error:

<IPython.core.display.Javascript object>
<IPython.core.display.HTML object>
Traceback (most recent call last):
  File ".\dpseg.py", line 379, in <module>
    run()
  File ".\dpseg.py", line 320, in run
    cerebro.plot()
  File "C:\ProgramData\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 996, in plot
    plotter.show()
  File "C:\ProgramData\Anaconda3\lib\site-packages\backtrader\plot\plot.py", line 817, in show
    self.mpyplot.show()
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\pyplot.py", line 272, in show
    return _show(*args, **kw)
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_nbagg.py", line 261, in show
    manager.show()
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_nbagg.py", line 90, in show
    self._create_comm()
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_nbagg.py", line 122, in _create_comm
    self.add_web_socket(comm)
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_webagg_core.py", line 433, in add_web_socket
    self.resize(w, h)
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_webagg_core.py", line 417, in resize
    self._send_event(
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_webagg_core.py", line 490, in _send_event
    s.send_json(payload)
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_nbagg.py", line 199, in send_json
    self.comm.send({'data': json.dumps(content)})
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\ipykernel\comm\comm.py", line 122, in send
    self._publish_msg('comm_msg',
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\ipykernel\comm\comm.py", line 66, in _publish_msg
    self.kernel.session.send(self.kernel.iopub_socket, msg_type,
AttributeError: 'NoneType' object has no attribute 'session'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\_pylab_helpers.py", line 72, in destroy_all
    manager.destroy()
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_nbagg.py", line 126, in destroy
    self._send_event('close')
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_webagg_core.py", line 490, in _send_event
    s.send_json(payload)
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\matplotlib\backends\backend_nbagg.py", line 199, in send_json
    self.comm.send({'data': json.dumps(content)})
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\ipykernel\comm\comm.py", line 122, in send
    self._publish_msg('comm_msg',
  File "C:\Users\Mislav\AppData\Roaming\Python\Python38\site-packages\ipykernel\comm\comm.py", line 66, in _publish_msg
    self.kernel.session.send(self.kernel.iopub_socket, msg_type,
AttributeError: 'NoneType' object has no attribute 'session'

I have found similar issue few years old, but I don't understand what is the solution to this. It is mentioning jupyter notebook. Do I have to use this package only inside jupyter?

主要语言
Python
星标
734
派生
411
平均合并
1 天 2 小时
30 天内合并 PR
9

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ipython/ipykernel 的其他 Issue

查看 ipython/ipykernel 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。