AttributeError when shutting down tensorflow kernel in Jupyterlab

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
File “C:\Users\dlin1\miniconda3\lib\site-packages\absl\”, line 951, in close
File “C:\Users\dlin1\miniconda3\lib\site-packages\ipykernel\”, line 428, in close
if self._exc:
AttributeError: ‘OutStream’ object has no attribute ‘_exc’

Any suggestions on how I can debug it?

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.

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.

In that case, I would recommend trying to upgrade:

  • ipykernel
  • jupyter-server
  • jupyterlab-server
  • jupyterlab
  • nbclassic

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?