Closed zyll123 closed 3 months ago
According to the import error, it seems that python import matplotlib from the global environment (/home1/yzhang/.local/lib/python3.9/site-packages/matplotlib/cm.py), although 'which python' shows i am using '/public/home/yzhang/micromamba/envs/Spatial/bin/python'. The matplotlib under '/home1/yzhang/.local/lib/python3.9/site-packages/matplotlib/cm.py' is indeed version 3.9.0. Is it a issue about the import path?
the problem is the squidpy version, I would install the latest squidpy version in your environment
I solved this by checking
import sys
for path in sys.path:
print(path)
and I found that the path for global environment was ahead of path for micromamba environment:
/public/home/yzhang/micromamba/envs/Spatial/lib/python39.zip
/public/home/yzhang/micromamba/envs/Spatial/lib/python3.9
/public/home/yzhang/micromamba/envs/Spatial/lib/python3.9/lib-dynload
/home1/yzhang/.local/lib/python3.9/site-packages
/public/home/yzhang/micromamba/envs/Spatial/lib/python3.9/site-packages
So I changed the sys path to put micromamba environment ahead of global one:
env_site_packages = '/public/home/yzhang/micromamba/envs/Spatial/lib/python3.9/site-packages'
user_site_packages = '/home1/yzhang/.local/lib/python3.9/site-packages'
sys.path.remove(env_site_packages)
sys.path.insert(sys.path.index(user_site_packages), env_site_packages)
for path in sys.path:
print(path)
Now the import works well
Description
I installed suidpy in a virtual environment. When I import the squidpy, an import error occurred :
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm'
Minimal reproducible example
I searched the internet and found it might be the problem caused by newest version of matplotlib, so I reinstalled matplotlib 3.8.3, but the same problem exited.
Traceback
Version
Python version: 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:50:21) squidpy version: 1.2.2