After conda update, python kernel crashes when matplotlib is used
Question:
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.
Answers:
Update 2021-11-06
- The default
pkgs/main
channel for conda
has reverted to using freetype 2.10.4
for Windows, per main / packages / freetype.
- If you are still experiencing the issue, use
conda list freetype
to check the version: freetype != 2.11.0
- If it is
2.11.0
, then change the version, per the solution, or conda update --all
(providing your default channel isn’t changed in the .condarc
config file).
Solution
- If this is occurring after installing Anaconda, updating
conda
or freetype
since Oct 27, 2021.
- Go to the
Anaconda
prompt and downgrade freetype 2.11.0
in any affected environment.
conda install freetype=2.10.4
- Relevant to any package using
matplotlib
and any IDE
- For example,
pandas.DataFrame.plot
and seaborn
- Jupyter, Spyder, VSCode, PyCharm, command line.
Discovery
- An issue occurs after updating with the most current updates from
conda
, released Friday, Oct 29.
- After updating with
conda update --all
, there’s an issue with anything related to matplotlib
in any IDE (not just Jupyter
).
- I tested this in
JupyterLab
, PyCharm
, and python
from the command prompt.
- PyCharm:
Process finished with exit code -1073741819
- JupyterLab: kernel just restarts and there are no associated errors or Traceback
- command prompt: a blank interactive matplotlib window will appear briefly, and then a new command line appears.
- The issue seems to be with
conda update --all
in (base)
, then any plot API that uses matplotlib
(e.g. seaborn
and pandas.DataFrame.plot
) kills the kernel in any environment.
- I had to reinstall Anaconda, but do not do an update of
(base)
, then my other environments worked.
- I have not figured out what specifically is causing the issue.
- I tested the issue with
python 3.8.12
and python 3.9.7
- Current Testing:
- Following is the
conda
revision log.
- Prior to
conda update --all
this environment was working, but after the updates, plotting with matplotlib
crashes the python kernel
2021-10-31 10:47:22 (rev 3)
bokeh {2.3.3 (defaults/win-64) -> 2.4.1 (defaults/win-64)}
click {8.0.1 (defaults/noarch) -> 8.0.3 (defaults/noarch)}
filelock {3.0.12 (defaults/noarch) -> 3.3.1 (defaults/noarch)}
freetype {2.10.4 (defaults/win-64) -> 2.11.0 (defaults/win-64)}
imagecodecs {2021.6.8 (defaults/win-64) -> 2021.8.26 (defaults/win-64)}
joblib {1.0.1 (defaults/noarch) -> 1.1.0 (defaults/noarch)}
lerc {2.2.1 (defaults/win-64) -> 3.0 (defaults/win-64)}
more-itertools {8.8.0 (defaults/noarch) -> 8.10.0 (defaults/noarch)}
pyopenssl {20.0.1 (defaults/noarch) -> 21.0.0 (defaults/noarch)}
scikit-learn {0.24.2 (defaults/win-64) -> 1.0.1 (defaults/win-64)}
statsmodels {0.12.2 (defaults/win-64) -> 0.13.0 (defaults/win-64)}
sympy {1.8 (defaults/win-64) -> 1.9 (defaults/win-64)}
tqdm {4.62.2 (defaults/noarch) -> 4.62.3 (defaults/noarch)}
xlwings {0.24.7 (defaults/win-64) -> 0.24.9 (defaults/win-64)}
- The issue seems to be
freetype
- Downgrading from
2.11.0
to 2.10.4
resolved the issue and made the environment work with matplotlib
- Went to post a bug report and discovered there is [Bug]: Matplotlib crashes Python #21511
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.
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.
UPDATE March 2nd 2023:
This is the Output captured from my kernel after dying:
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll
already initialized.
OMP: Hint: This means that multiple copies of the OpenMP runtime have
been linked into the program. That is dangerous since it can degrade
performance or cause incorrect results. The best thing to do is to
ensure that only a single OpenMP runtime is linked into the process,
e.g. by avoiding static linking of the OpenMP runtime in any library.
As an unsafe, unsupported, undocumented workaround you can set the
environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to
continue to execute, but that may cause crashes or silently produce
incorrect results. For more information, please see
http://www.intel.com/software/products/support/.
I was facing the similar problem, I fixed it by deleting the libiomp5md.dll duplicate file from Anaconda environment folder path this directory:
C:Usersyour-user-name.condaenvsyour_env_nameLibrarybinlibiomp5md.dll
actually downgrading freetype
didn’t work for me.
you can add ‘libiomp5md.dll’ back to Original file,it can fix kernel died temporarily but caused OMP error.
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.
Update 2021-11-06
- The default
pkgs/main
channel forconda
has reverted to usingfreetype 2.10.4
for Windows, per main / packages / freetype. - If you are still experiencing the issue, use
conda list freetype
to check the version:freetype != 2.11.0
- If it is
2.11.0
, then change the version, per the solution, orconda update --all
(providing your default channel isn’t changed in the.condarc
config file).
- If it is
Solution
- If this is occurring after installing Anaconda, updating
conda
orfreetype
since Oct 27, 2021. - Go to the
Anaconda
prompt and downgradefreetype 2.11.0
in any affected environment.conda install freetype=2.10.4
- Relevant to any package using
matplotlib
and any IDE- For example,
pandas.DataFrame.plot
andseaborn
- Jupyter, Spyder, VSCode, PyCharm, command line.
- For example,
Discovery
- An issue occurs after updating with the most current updates from
conda
, released Friday, Oct 29. - After updating with
conda update --all
, there’s an issue with anything related tomatplotlib
in any IDE (not justJupyter
).- I tested this in
JupyterLab
,PyCharm
, andpython
from the command prompt. - PyCharm:
Process finished with exit code -1073741819
- JupyterLab: kernel just restarts and there are no associated errors or Traceback
- command prompt: a blank interactive matplotlib window will appear briefly, and then a new command line appears.
- I tested this in
- The issue seems to be with
conda update --all
in(base)
, then any plot API that usesmatplotlib
(e.g.seaborn
andpandas.DataFrame.plot
) kills the kernel in any environment. - I had to reinstall Anaconda, but do not do an update of
(base)
, then my other environments worked. - I have not figured out what specifically is causing the issue.
- I tested the issue with
python 3.8.12
andpython 3.9.7
- Current Testing:
- Following is the
conda
revision log. - Prior to
conda update --all
this environment was working, but after the updates, plotting withmatplotlib
crashes the python kernel
- Following is the
2021-10-31 10:47:22 (rev 3)
bokeh {2.3.3 (defaults/win-64) -> 2.4.1 (defaults/win-64)}
click {8.0.1 (defaults/noarch) -> 8.0.3 (defaults/noarch)}
filelock {3.0.12 (defaults/noarch) -> 3.3.1 (defaults/noarch)}
freetype {2.10.4 (defaults/win-64) -> 2.11.0 (defaults/win-64)}
imagecodecs {2021.6.8 (defaults/win-64) -> 2021.8.26 (defaults/win-64)}
joblib {1.0.1 (defaults/noarch) -> 1.1.0 (defaults/noarch)}
lerc {2.2.1 (defaults/win-64) -> 3.0 (defaults/win-64)}
more-itertools {8.8.0 (defaults/noarch) -> 8.10.0 (defaults/noarch)}
pyopenssl {20.0.1 (defaults/noarch) -> 21.0.0 (defaults/noarch)}
scikit-learn {0.24.2 (defaults/win-64) -> 1.0.1 (defaults/win-64)}
statsmodels {0.12.2 (defaults/win-64) -> 0.13.0 (defaults/win-64)}
sympy {1.8 (defaults/win-64) -> 1.9 (defaults/win-64)}
tqdm {4.62.2 (defaults/noarch) -> 4.62.3 (defaults/noarch)}
xlwings {0.24.7 (defaults/win-64) -> 0.24.9 (defaults/win-64)}
- The issue seems to be
freetype
- Downgrading from
2.11.0
to2.10.4
resolved the issue and made the environment work withmatplotlib
- Downgrading from
- Went to post a bug report and discovered there is [Bug]: Matplotlib crashes Python #21511
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.
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
frommain/pkg
toconda-forge
channel - reinstall
mkl
packageconda -c intel mkl
- reinstall
matplotlib=4.3
fromconda-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.
UPDATE March 2nd 2023:
This is the Output captured from my kernel after dying:
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll
already initialized.OMP: Hint: This means that multiple copies of the OpenMP runtime have
been linked into the program. That is dangerous since it can degrade
performance or cause incorrect results. The best thing to do is to
ensure that only a single OpenMP runtime is linked into the process,
e.g. by avoiding static linking of the OpenMP runtime in any library.
As an unsafe, unsupported, undocumented workaround you can set the
environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to
continue to execute, but that may cause crashes or silently produce
incorrect results. For more information, please see
http://www.intel.com/software/products/support/.
I was facing the similar problem, I fixed it by deleting the libiomp5md.dll duplicate file from Anaconda environment folder path this directory:
C:Usersyour-user-name.condaenvsyour_env_nameLibrarybinlibiomp5md.dll
actually downgrading freetype
didn’t work for me.
you can add ‘libiomp5md.dll’ back to Original file,it can fix kernel died temporarily but caused OMP error.