conda-forge / matplotlib-feedstock

A conda-smithy repository for matplotlib.
BSD 3-Clause "New" or "Revised" License
22 stars 57 forks source link

python kernel dies on import matplotlib.pyplot in clean miniconda with only matplotlib from conda-forge installed #317

Closed zippylab closed 2 years ago

zippylab commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

Creating a clean miniconda environment, and only installing the matplotlib package from conda-forge like this:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh ./Miniconda3-latest-Linux-x86_64.sh conda install -c conda-forge matplotlib

leads to an environment where importing matplotlib kills the python kernel:

(base) login-1(~)> python
Python 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Segmentation fault (core dumped)
(base) login-1(~)>

If, instead of installing matplotlib from conda-forge, I omit the -c conda-forge and let conda choose a default repo, the matplotlib package installed works fine.

Installed packages

# packages in environment at /home/zippy/miniconda3:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             4.5                       1_gnu
brotli                    1.0.9                h7f98852_5    conda-forge
brotli-bin                1.0.9                h7f98852_5    conda-forge
brotlipy                  0.7.0           py39h27cfd23_1003
ca-certificates           2021.10.8            ha878542_0    conda-forge
certifi                   2021.10.8        py39hf3d152e_2    conda-forge
cffi                      1.15.0           py39hd667e15_1
charset-normalizer        2.0.4              pyhd3eb1b0_0
conda                     4.12.0           py39hf3d152e_0    conda-forge
conda-content-trust       0.1.1              pyhd3eb1b0_0
conda-package-handling    1.7.3            py39h27cfd23_1
cryptography              36.0.0           py39h9ce1e76_0
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
dbus                      1.13.6               he372182_0    conda-forge
expat                     2.2.10               h9c3ff4c_0    conda-forge
fontconfig                2.13.1               h6c09931_0
fonttools                 4.25.0             pyhd3eb1b0_0
freetype                  2.11.0               h70c0345_0
glib                      2.69.1               h4ff587b_1
gst-plugins-base          1.14.0               hbbd80ab_1
gstreamer                 1.14.0               h28cd5cc_2
icu                       58.2              hf484d3e_1000    conda-forge
idna                      3.3                pyhd3eb1b0_0
jpeg                      9d                   h7f8727e_0
kiwisolver                1.3.2            py39h295c915_0
lcms2                     2.12                 hddcbb42_0    conda-forge
ld_impl_linux-64          2.35.1               h7274673_9
libblas                   3.9.0           11_linux64_openblas    conda-forge
libbrotlicommon           1.0.9                h7f98852_5    conda-forge
libbrotlidec              1.0.9                h7f98852_5    conda-forge
libbrotlienc              1.0.9                h7f98852_5    conda-forge
libcblas                  3.9.0           11_linux64_openblas    conda-forge
libffi                    3.3                  he6710b0_2
libgcc-ng                 9.3.0               h5101ec6_17
libgfortran-ng            11.2.0              h69a702a_14    conda-forge
libgfortran5              11.2.0              h5c6108e_14    conda-forge
libgomp                   9.3.0               h5101ec6_17
liblapack                 3.9.0           11_linux64_openblas    conda-forge
libopenblas               0.3.17          pthreads_h8fe5266_1    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libstdcxx-ng              9.3.0               hd4cf53a_17
libtiff                   4.2.0                h85742a9_0
libuuid                   1.0.3                h7f8727e_2
libwebp-base              1.2.2                h7f8727e_0
libxcb                    1.13              h7f98852_1003    conda-forge
libxml2                   2.9.12               h03d6c58_0
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
matplotlib                3.5.1            py39hf3d152e_0    conda-forge
matplotlib-base           3.5.1            py39ha18d171_1
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
ncurses                   6.3                  h7f8727e_2
numpy                     1.20.3           py39hdbf815f_1    conda-forge
olefile                   0.46               pyh9f0ad1d_1    conda-forge
openssl                   1.1.1n               h7f8727e_0
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pcre                      8.45                 h9c3ff4c_0    conda-forge
pillow                    7.2.0            py39h6f3857e_2    conda-forge
pip                       21.2.4           py39h06a4308_0
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pycosat                   0.6.3            py39h27cfd23_0
pycparser                 2.21               pyhd3eb1b0_0
pyopenssl                 21.0.0             pyhd3eb1b0_1
pyparsing                 3.0.7              pyhd8ed1ab_0    conda-forge
pyqt                      5.9.2            py39h2531618_6
pysocks                   1.7.1            py39h06a4308_0
python                    3.9.7                h12debd9_1
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
qt                        5.9.7                h5867ecd_1
readline                  8.1.2                h7f8727e_1
requests                  2.27.1             pyhd3eb1b0_0
ruamel_yaml               0.15.100         py39h27cfd23_0
setuptools                58.0.4           py39h06a4308_0
sip                       4.19.13          py39h295c915_0
six                       1.16.0             pyhd3eb1b0_0
sqlite                    3.37.0               hc218d9a_0
tk                        8.6.11               h1ccaba5_0
tornado                   6.1              py39h3811e60_1    conda-forge
tqdm                      4.62.3             pyhd3eb1b0_1
tzdata                    2021e                hda174b7_0
urllib3                   1.26.7             pyhd3eb1b0_0
wheel                     0.37.1             pyhd3eb1b0_0
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xz                        5.2.5                h7b6447c_0
yaml                      0.2.5                h7b6447c_0
zlib                      1.2.11               h7f8727e_4
zstd                      1.4.9                ha95c52a_0    conda-forge

Environment info

active environment : base
    active env location : /home/zippy/miniconda3
            shell level : 1
       user config file : /home/zippy/.condarc
 populated config files :
          conda version : 4.12.0
    conda-build version : not installed
         python version : 3.9.7.final.0
       virtual packages : __linux=5.3.18=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/zippy/miniconda3  (writable)
      conda av data dir : /home/zippy/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/zippy/miniconda3/pkgs
                          /home/zippy/.conda/pkgs
       envs directories : /home/zippy/miniconda3/envs
                          /home/zippy/.conda/envs
               platform : linux-64
             user-agent : conda/4.12.0 requests/2.27.1 CPython/3.9.7 Linux/5.3.18-150300.59.49-default opensuse-leap/15.3 glibc/2.31
                UID:GID : 2063:2063
             netrc file : None
           offline mode : False
dopplershift commented 2 years ago

Looks like you have an environment with a big mix of packages from conda-forge and defaults; there's probably some conflict that's causing the core dump. What happens if you create a new environment using just conda-forge:

conda create -n testenv python=3.9 matplotlib
conda activate testenv
python -c 'import matplotlib.pyplot as plt'
zippylab commented 2 years ago

@dopplershift That does work without error, but it seems like that is kind of equivalent to what I also observed worked: creating the clean miniconda env then installing matplotlib without specifying conda-forge as repo.

That testenv does show a different package environment, without all the conda-forge ones mixed in. However, I believe all the ones brought in from conda-forge in my original package environment listing were those that are installed along with matplotlib itself (i.e., I think all the conda-forge items in the original list stemmed from installing matplotlib from conda-forge).

(testenv) login-1(~)> conda list
# packages in environment at /home/zippy/miniconda3/envs/testenv:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             4.5                       1_gnu
blas                      1.0                         mkl
brotli                    1.0.9                he6710b0_2
ca-certificates           2022.3.29            h06a4308_0
certifi                   2021.10.8        py39h06a4308_2
cycler                    0.11.0             pyhd3eb1b0_0
dbus                      1.13.18              hb2f20db_0
expat                     2.4.4                h295c915_0
fontconfig                2.13.1               h6c09931_0
fonttools                 4.25.0             pyhd3eb1b0_0
freetype                  2.11.0               h70c0345_0
giflib                    5.2.1                h7b6447c_0
glib                      2.69.1               h4ff587b_1
gst-plugins-base          1.14.0               h8213a91_2
gstreamer                 1.14.0               h28cd5cc_2
icu                       58.2                 he6710b0_3
intel-openmp              2021.4.0          h06a4308_3561
jpeg                      9d                   h7f8727e_0
kiwisolver                1.3.2            py39h295c915_0
lcms2                     2.12                 h3be6417_0
ld_impl_linux-64          2.35.1               h7274673_9
libffi                    3.3                  he6710b0_2
libgcc-ng                 9.3.0               h5101ec6_17
libgomp                   9.3.0               h5101ec6_17
libpng                    1.6.37               hbc83047_0
libstdcxx-ng              9.3.0               hd4cf53a_17
libtiff                   4.2.0                h85742a9_0
libuuid                   1.0.3                h7f8727e_2
libwebp                   1.2.2                h55f646e_0
libwebp-base              1.2.2                h7f8727e_0
libxcb                    1.14                 h7b6447c_0
libxml2                   2.9.12               h03d6c58_0
lz4-c                     1.9.3                h295c915_1
matplotlib                3.5.1            py39h06a4308_1
matplotlib-base           3.5.1            py39ha18d171_1
mkl                       2021.4.0           h06a4308_640
mkl-service               2.4.0            py39h7f8727e_0
mkl_fft                   1.3.1            py39hd3c417c_0
mkl_random                1.2.2            py39h51133e4_0
munkres                   1.1.4                      py_0
ncurses                   6.3                  h7f8727e_2
numpy                     1.21.2           py39h20f2e39_0
numpy-base                1.21.2           py39h79a1101_0
openssl                   1.1.1n               h7f8727e_0
packaging                 21.3               pyhd3eb1b0_0
pcre                      8.45                 h295c915_0
pillow                    9.0.1            py39h22f2fdc_0
pip                       21.2.4           py39h06a4308_0
pyparsing                 3.0.4              pyhd3eb1b0_0
pyqt                      5.9.2            py39h2531618_6
python                    3.9.12               h12debd9_0
python-dateutil           2.8.2              pyhd3eb1b0_0
qt                        5.9.7                h5867ecd_1
readline                  8.1.2                h7f8727e_1
setuptools                58.0.4           py39h06a4308_0
sip                       4.19.13          py39h295c915_0
six                       1.16.0             pyhd3eb1b0_1
sqlite                    3.38.2               hc218d9a_0
tk                        8.6.11               h1ccaba5_0
tornado                   6.1              py39h27cfd23_0
tzdata                    2022a                hda174b7_0
wheel                     0.37.1             pyhd3eb1b0_0
xz                        5.2.5                h7b6447c_0
zlib                      1.2.11               h7f8727e_4
zstd                      1.4.9                haebb681_0
(testenv) login-1(~)>
dopplershift commented 2 years ago

Running an environment that contains a mix of packages from both the defaults channel and the conda-forge channel is not a configuration that we support, specifically because it often results in hard to debug problems like this one. The fact that using packages from the conda-forge channel works fine indicates that everything is working as intended.

If someone can point out something that we're doing wrong here, I'm happy to merge a PR fixing it. There are so many possible causes for this kind of crash (incompatible C libraries, compiler flags, linked library versions, etc.) when running in an environment with packages from the defaults channel. In the end, the cause of the incompatibility likely can't even be resolved in this recipe.

The conda-forge channel at this point should have everything, so is there some reason you want to run a mix?

zippylab commented 2 years ago

@dopplershift No reason I want/need to run a mix. Maybe the issue is I'm not setting up the bare starting-point miniconda environment the right way, so that it has only conda-forge packages? I was just using the installer script from repo.anaconda.com:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x ./Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
....
dopplershift commented 2 years ago

My usual way is to add the conda-forge channel and then install things into other environments (though at this point my base environment is all conda-forge):

conda config --add channels conda-forge
conda update -n base --all

You could also install using our pre-configured "miniforge" installers: https://github.com/conda-forge/miniforge/releases/