Incompatibility with new anndata 0.10.9
Issue
There is a new anndata release incompatible with scVI
Error message
> import scvi
ImportError: cannot import name 'AlignedViewMixin' from 'anndata._core.aligned_mapping' (/local_disk0/.ephemeral_nfs/envs/pythonEnv-41a17f4f-ae47-4ddc-a406-410dcbd282df/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py)
Temporary fix
Pin down anndata:
pip install anndata==0.10.8
Hi, thanks for posting this. Please post the full error as it makes it easier to figure out what's causing this. I opened the issue for MuData as it seems like this is causing the issue: https://github.com/scverse/mudata/issues/77.
Fixed in MuData.
Hello, I hope this message finds you well. I am getting the same error message having to do with scvi and anndata package incompatibilities when importing the newest version of both packages. I tried the temporary fix of downgrading anndata to version 0.10.8 but then got a message saying:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. scvi-tools 1.3.0 requires anndata>=0.11, but you have anndata 0.10.8 which is incompatible.
Any suggestions here? Thank you for taking the time to read this.
The entire original error message is pasted below for reference. `--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[10], line 1 ----> 1 import scvi
File ~/.local/lib/python3.10/site-packages/scvi/init.py:11 8 from ._settings import settings 10 # this import needs to come after prior imports to prevent circular import ---> 11 from . import data, model, external, utils 13 from importlib.metadata import version 15 package_name = "scvi-tools"
File ~/.local/lib/python3.10/site-packages/scvi/data/init.py:4 1 from anndata import read_h5ad 2 from anndata.io import read_csv, read_loom, read_text ----> 4 from ._anntorchdataset import AnnTorchDataset 5 from ._datasets import ( 6 annotation_simulation, 7 brainlarge_dataset, (...) 23 synthetic_iid, 24 ) 25 from ._manager import AnnDataManager, AnnDataManagerValidationCheck
File ~/.local/lib/python3.10/site-packages/scvi/data/_anntorchdataset.py:20 17 import torch 19 from ._manager import AnnDataManager ---> 20 from ._utils import registry_key_to_default_dtype, scipy_to_torch_sparse 22 logger = logging.getLogger(name) 24 SparseDataset = (CSRDataset, CSCDataset)
File ~/.local/lib/python3.10/site-packages/scvi/data/_utils.py:15 13 from anndata.abc import CSCDataset, CSRDataset 14 from anndata.io import read_elem ---> 15 from mudata import MuData 16 from torch import as_tensor, sparse_csc_tensor, sparse_csr_tensor 18 from scvi import REGISTRY_KEYS, settings
File ~/.local/lib/python3.10/site-packages/mudata/init.py:3 1 """Multimodal omics analysis framework""" ----> 3 from ._core.mudata import MuData 4 from ._core import utils 5 from ._core.io import *
File ~/.local/lib/python3.10/site-packages/mudata/_core/mudata.py:21 19 from anndata import AnnData 20 from anndata.utils import convert_to_dict ---> 21 from anndata._core.aligned_mapping import ( 22 AxisArrays, 23 AlignedViewMixin, 24 AxisArraysBase, 25 PairwiseArrays, 26 PairwiseArraysView, 27 ) 28 from anndata._core.views import DataFrameView 30 from .file_backing import MuDataFileManager
ImportError: cannot import name 'AlignedViewMixin' from 'anndata._core.aligned_mapping' (/home/jupyter/.local/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py)`
please start a clean new conda env and install scvi-tools 1.3 , it will install the needed packages and should be ok
Hello, thanks for the response! I tried this and after re-installing scvi (version 1.3.0) and anndata (version 0.11.3) I still am getting the same error. Do you have any other suggestions? Thanks.
Your issue here is MuData and not AnnData or scvi-tools. Can you verify that the issue arises when you just import MuData and then follow their installation guideline?
The same issue does arise when I import MuData.
`import mudata as md
from mudata import MuData`
ImportError: cannot import name 'AlignedViewMixin' from 'anndata._core.aligned_mapping' (/home/jupyter/.local/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py)
Hi! Just following up on this issue. Do you have any suggestions on where to go from here? I get the same error when I follow MuData installation guideline. Should I reach out to the MuData team for assistance? Thank you for your help thus far.
ImportError: cannot import name 'AlignedViewMixin' from 'anndata._core.aligned_mapping'
Like I suggested before, please start a clean new conda env and install scvi-tools 1.3 , it will install the needed packages for both anndata and mudata and should be ok. Use python 3.12.
Hi, thank you for your suggestions! I wanted to follow up with what worked for solving this issue. I upgraded MuData to the newest version 0.3.1, which is compatible with scvi version 1.3.0. I also wanted to note that in order to load existing scvi models I had to downgrade pandas to version 1.5.3.
I have the same error, and there is no use of pip install anndata==0.10.8. Moreover, my MuData is the newest version 0.3.2
@joeyQX Im not quite following, but anndata 0.10.x is at least 1 year old, and we can make certain it will be supported with most recent scvi-tools (e.g 1.4.x). I suggest starting a clean environment and setting up scvi-tools, which will automatically install all other needed packages correct versions. Let me know if you have other questions.
@joeyQX Im not quite following, but anndata 0.10.x is at least 1 year old, and we can make certain it will be supported with most recent scvi-tools (e.g 1.4.x). I suggest starting a clean environment and setting up scvi-tools, which will automatically install all other needed packages correct versions. Let me know if you have other questions.
thx!