scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
400 stars 70 forks source link

matplotlib update leads to import error #827

Closed LouisK92 closed 1 month ago

LouisK92 commented 1 month ago

Description

matplotlib release v3.9.0 introduces an import error for me when import squidpy.

Downgrading to v3.8.4 solves the issue. (pip install matplotlib==3.8.4)

Minimal reproducible example

import squidpy

Traceback

...
    import squidpy as sq
  File "/.../lib/python3.10/site-packages/squidpy/__init__.py", line 3, in <module>
    from squidpy import datasets, gr, im, pl, read, tl
  File "/.../lib/python3.10/site-packages/squidpy/pl/__init__.py", line 12, in <module>
    from squidpy.pl._spatial import spatial_scatter, spatial_segment
  File "/.../lib/python3.10/site-packages/squidpy/pl/_spatial.py", line 17, in <module>
    from squidpy.pl._spatial_utils import (
  File "/.../lib/python3.10/site-packages/squidpy/pl/_spatial_utils.py", line 29, in <module>
    from matplotlib.cm import get_cmap
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm'

Version

1.4.1

groverj3 commented 1 month ago

Same issue today on python 3.10.4 with matplotlib 3.9.0. Downgrading matplotlib to the last version I had installed in another virtualenv (3.8.4) allowed me to import squidpy.

earmingol commented 1 month ago

Same error here, this makes fail the CI of a tool I'm developing.

andrew-weisman commented 1 month ago

Same here, on Ubuntu 22.04.4 LTS, here is how I reproduce:

sudo apt-get update && sudo apt-get upgrade
conda update -n base -c conda-forge conda
conda create -n barebones python pip pygeos
conda activate barebones
pip install matplotlib squidpy
python
import squidpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/XXXX/programs/miniconda3/envs/barebones/lib/python3.11/site-packages/squidpy/__init__.py", line 3, in <module>
    from squidpy import datasets, gr, im, pl, read, tl
  File "/home/XXXX/programs/miniconda3/envs/barebones/lib/python3.11/site-packages/squidpy/pl/__init__.py", line 12, in <module>
    from squidpy.pl._spatial import spatial_scatter, spatial_segment
  File "/home/XXXX/programs/miniconda3/envs/barebones/lib/python3.11/site-packages/squidpy/pl/_spatial.py", line 17, in <module>
    from squidpy.pl._spatial_utils import (
  File "/home/XXXX/programs/miniconda3/envs/barebones/lib/python3.11/site-packages/squidpy/pl/_spatial_utils.py", line 29, in <module>
    from matplotlib.cm import get_cmap
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm' (/home/XXXX/programs/miniconda3/envs/barebones/lib/python3.11/site-packages/matplotlib/cm.py)
michalk8 commented 1 month ago

Thanks for pointing this out, will fix over the weekend!

giovp commented 1 month ago

hi, I've just installed squidpy from main in a fresh environment and tried to import squidpy and it works, versions:

❯ python
Python 3.10.14 (main, May  6 2024, 14:42:37) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import squidpy as sq
>>> 
❯ conda list | grep matplotlib
matplotlib                3.9.0                    pypi_0    pypi
matplotlib-scalebar       0.8.1                    pypi_0    pypi

I think this is because it is fixed in main but not release, will cut release now quickly

giovp commented 1 month ago

hi all, thank you for reporting, this has been fixed in the latest release on pypi

andrew-weisman commented 1 month ago

Confirmed it works now, thanks for fixing!

earmingol commented 1 month ago

It works for me too, now the CI of my tool is passing the tests. Thank you!