'After conda update, python kernel crashes when matplotlib is used

I have create this simple env with conda:

conda create -n test python=3.8.5 pandas scipy numpy matplotlib seaborn jupyterlab

The following code in jupyter lab crashes the kernel :

import matplotlib.pyplot as plt

plt.subplot()

I don't face the problem on Linux. The problem is when I try on Windows 10.

There are no errors on the jupyter lab console (where I started the server), and I have no idea where to investigate.



Solution 1:[1]

I had the same issue and after a fair amount of investigation and troubleshooting, the fix was pretty straight forward:

conda update -c anaconda numpy

conda upgrade -c conda-forge matplotlib

After that it ran fine and my visuals plotted without issue.

Solution 2:[2]

For anybody that downgrading to freetype=2.10.4 didn't work. In my case the issue happened after installing the new version of scikit-learn=1.11 from conda-forge channel. After trying out many options the following worked for me:

  • reinstall numpy from main/pkg to conda-forge channel
  • reinstall mkl package conda -c intel mkl
  • reinstall matplotlib=4.3 from conda-forge

It's quite a drastic measure, since you have to reinstall all dependecies that rely on NumPy (Pandas, TensorFlow etc.), but it was the only one that worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman
Solution 2 xan