mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.6k stars 1.93k forks source link

Older Versions of Seaborn Incompatible with Matplotlib 3.9.x #3750

Closed GilChrist19 closed 3 months ago

GilChrist19 commented 3 months ago

I am unable to import seaborn when installed to an environment with matplotlib 3.9.x.

mamba create -y -n test python seaborn matplotlib statannotations
mamba activate test
python
import seaborn as sb  # This is where it fails.

Error is: AttributeError: module 'matplotlib.cm' has no attribute 'register_cmap'

However,

mamba create -y -n test python seaborn matplotlib=3.8 statannotations
mamba activate test
python
import seaborn as sb  # fine now

and

mamba create -y -n test python seaborn
mamba activate test
python
import seaborn as sb  # still fine

both work fine.

I realize an older version of seaborn is being installed (0.11 I believe), due to compatibility with statannotations, and that's what's struggling with the matplotlib versions.

Is there a way to set the matplotlib dependency <3.9 for older versions of seaborn, as that's when they updated the internal API.

mwaskom commented 3 months ago

Hi, I’m not sure I understand the question here. If you are setting up an environment with an archaic version of seaborn, you should require a suitably old and compatible version of matplotlib as well.

GilChrist19 commented 3 months ago

Hello Michael,

That's true - totally agree.

The problem is that there's no rule for the environment/dependency solver to enforce that, something like this line in the current versions. Therefore Mamba builds the environment with the current version of matplotlib even though it's incompatible.

Not sure if it's possible to update "matplotlib>=3.4,!=3.6.1", to something like "matplotlib>=3.4,!=3.6.1,<3.9", in older versions to ensure matching dependencies upon installation.

~Jared

mwaskom commented 3 months ago

It’s not possible to retroactively change older versions. It sounds like you are maybe installing a third package that pins an old version of seaborn. I would say that package would have the responsibility to also limit the matplotlib version that it is compatible with, as it is transitively incompatible with 3.9 via seaborn at least.