Import issue: AttributeError: 'NoneType' object has no attribute 'session'
- Dominant language
- Python
- Stars
- 734
- Forks
- 412
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
Description
When import the package inside VScode I get an error:
```
Traceback (most recent call last):
File ".\dpseg.py", line 379, in
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?
Contributor guide
Research direction
Start with the traceback paths in ipykernel/comm/comm.py and matplotlib/backends/backend_nbagg.py, then reproduce cerebro.plot() from VS Code. Compare that execution context with the Jupyter-related behavior described in the issue. Done should mean the failure is reproduced and either fixed or the supported execution context is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100