# AttributeError when shutting down tensorflow kernel in Jupyterlab

**URL:** <https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558>\
**Category:** JupyterLab\
**Created:** [November 5, 2021, 4:42am UTC](https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558 "2021-11-05T04:42:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdlin1](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/kdlin1/32/5633_2.png) [@kdlin1](https://discourse.jupyter.org/u/kdlin1)\
**Post date:** [November 5, 2021, 4:42am UTC](https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558/1 "2021-11-05T04:42:29Z")

</div>

I am a long time Mac user, but switched to Windows recently. I rebuilt the conda environment to run tensorflow in Windows. When I shut down a kernel in Jupyterlab, I run into the following error messages:

[I 2021-11-04 21:34:24.405 ServerApp] Kernel shutdown: c7b2b2fd-f799-47cd-babb-8775ee1c1be4  
Error in atexit._run\_exitfuncs:  
Traceback (most recent call last):  
File "C:\Users\dlin1\miniconda3\lib\logging\_init_.py", line 2127, in shutdown  
h.close()  
File “C:\Users\dlin1\miniconda3\lib\site-packages\absl\logging\__init_\_.py”, line 951, in close  
self.stream.close()  
File “C:\Users\dlin1\miniconda3\lib\site-packages\ipykernel\iostream.py”, line 428, in close  
if self.\_exc:  
AttributeError: ‘OutStream’ object has no attribute ‘\_exc’

Any suggestions on how I can debug it?

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 6, 2021, 11:56am UTC](https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558/2 "2021-11-06T11:56:34Z")

</div>

I would check versions - are you using the latest versions? Are you using a too recent version of something that has not been widely adopted yet (like Python 3.10)? Once you narrow down what is the problematic version I would report it in an appropriate GitHub repository.

---

<div class="post-metadata">

**Author:** ![kdlin1](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/kdlin1/32/5633_2.png) [@kdlin1](https://discourse.jupyter.org/u/kdlin1)\
**Post date:** [November 7, 2021, 5:54am UTC](https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558/3 "2021-11-07T05:54:11Z")

</div>

I am using python 3.8.x and tensorflow 3.5.0, among others. So I don’t think I am using the latest versions. Can you please recommend some packages to check/verify? I understand that the latest packages may cause issues. But it would be good to know what packages to check for this type of errors. Thank you.

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 7, 2021, 11:59am UTC](https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558/4 "2021-11-07T11:59:56Z")

</div>

In that case, I would recommend trying to upgrade:

- `ipykernel`
- `jupyter-server`
- `jupyterlab-server`
- `jupyterlab`
- `nbclassic`

---

<div class="post-metadata">

**Author:** ![kdlin1](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/kdlin1/32/5633_2.png) [@kdlin1](https://discourse.jupyter.org/u/kdlin1)\
**Post date:** [November 7, 2021, 11:00pm UTC](https://discourse.jupyter.org/t/attributeerror-when-shutting-down-tensorflow-kernel-in-jupyterlab/11558/5 "2021-11-07T23:00:41Z")

</div>

Thanks. I had upgraded these to the latest in my debugging. But the error messages still show…

I tried to important the packages I use one by one and see which one would cause the error messages. It turns out that tensorflow is what causes the issue. I just have one line “import tensorflow as tf” in the script, run the script, and shut down the kernel. Then it shows the error messages.

Isn’t this odd?
