I'm getting kernel restart issues in Spyder from scipy.cluster.hierarchy.dendrogram. However, the kernel doesn't die every time. I have one array D that kills the kernel, while D+1 does not. This code generates a random large array that crashes the kernel:
import numpy as np
import scipy.cluster.hierarchy as sch
from scipy.spatial.distance import squareform
n = 5674
np.random.seed(0)
D = np.random.randint(35,size=(n,n))
for i in range(n):
D[i,i] = 0
for i in range(n-1):
for j in range(i+1,n):
D[j,i] = D[i,j]
condensedD = squareform(D)
Y1= sch.linkage(condensedD)
Z1 = sch.dendrogram(Y1)
In up-to-date Anaconda (conda update --all as of 11/6/2021), I get the following error (posted in full on https://github.com/spyder-ide/spyder/issues/16757), and the kernel freezes but doesn't automatically restart:
File "C:\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\utils\manager.py", line 92, in _kill_kernel
self.kill_proc_tree(self.kernel.pid)
AttributeError: 'SpyderKernelManager' object has no attribute 'kernel'
When I followed the solution proposed on GitHub (conda install jupyter_client=6.1.12 freetype=2.10.4), I stopped getting the AttributeError, but the kernel just says Restarting kernel... every time without throwing any errors.
Apparently I'm not the only with who is dealing with this (https://issueexplorer.com/issue/spyder-ide/spyder/16575). I tried running Spyder from the Powershell and this didn't help either (Spyder3 - AttributeError: 'SpyderKernel' object has no attribute '_show_mpl_backend_errors'). Other people seem to have a similar issue with matplotlib (https://github.com/spyder-ide/spyder/issues/16659). The freetype=2.10.4 solution worked for some people (https://githubmemory.com/repo/spyder-ide/spyder/issues/16729), but not for me.
Any help would be greatly appreciated.
Edit: setting ipykernel=6.2.0 didn't work, either (following https://stackoverflow.com/a/69527465/12497141).