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 摘要。