0

All of the script had been running perfectly fine in Jupyter Notebook. But, I am facing an issue "The kernel appears to have died. It will restart automatically" when I deploy python code using Jupyter Notebook on Azure. All parts of the code run fine, except for the last line of the code (where I open an image using OpenCV). Moreover, I have installed all necessary libraries. This is the error message that I am getting:

Kernel Restarting
The kernel appears to have died. It will restart automatically.

And, here is the skeleton of my Python Code:

!pip install opencv-python
!pip install numpy
!pip install tensorflow
!pip install -U numpy
!pip install ipykernel ipython jupyter_client jupyter_core traitlets ipython_genutils
!pip install numpy --upgrade
!pip install nomkl
!pip update --all
!apt-get update
!apt-get install ffmpeg libsm6 libxext6  -y
!pip install matplotlib
!pip install -c intel mkl



import cv2
image=cv2.imread('img_1.jpg')
image.shape
image[0]
import matplotlib.pyplot as plt
plt.imshow(image)

# from here I can get an error

while True:
   cv2.imshow('Image',image)
   if cv2.waitKey(2) == 27:
    # 27 is ASCII os Escape
    break
cv2.destroyAllWindows()


How do I solve this problem?

I checked some of the previous links on stackoverflow: Jupyter | The kernel appears to have died. It will restart automatically |

I tried the solution given in the link, unfortunately, it has not worked for my case :(

Burulai
  • 1
  • 1

1 Answers1

0

Kernel Restarting The kernel appears to have died. It will restart automatically.

I have got the same issue. I have fixed by reinstalling the necessary packages again. I hope you already done it if not try to reinstall the necessary packages matplotlib, NumPy, TensorFlow & others.

Instead of using !pip install opencv-python you can use pip install opencv-python--headless.

Refer SO thread created by Mike de H for similar kind of issue.

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15