Open 1QiGuo opened 1 month ago
Hi @1QiGuo,
This is likely an issue related to MuData. Can you try up- downgrading your current version. If this doesn't work, I can only help if you provide your environment.
Daniel
Hi @dbdimitrov,
I have the same issue:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 34
31 import matplotlib.lines as mlines
33 # C2C communication
---> 34 import liana as li
35 import decoupler as dc
36 import omnipath as op
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/__init__.py:3](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/__init__.py#line=2)
1 __version__ = '1.4.0'
----> 3 from liana import method as mt, plotting as pl, resource as rs, multi as mu, utils as ut, testing
5 # done after everything has been imported (adapted from scanpy)
6 import sys
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/__init__.py:3](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/__init__.py#line=2)
1 import numpy as np
----> 3 from liana.method.sc._Method import Method, MethodMeta, _show_methods
4 from liana.method.sc._rank_aggregate import AggregateClass, _rank_aggregate_meta as aggregate_meta
5 from liana.method.sc import cellphonedb, connectome, logfc, natmi, singlecellsignalr, geometric_mean, cellchat, scseqcomm
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/__init__.py:1](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/__init__.py#line=0)
----> 1 from ._rank_aggregate import _rank_aggregate_meta
2 from ._cellphonedb import cellphonedb
3 from ._logfc import logfc
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/_rank_aggregate.py:3](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/_rank_aggregate.py#line=2)
1 from __future__ import annotations
----> 3 from liana.method.sc._Method import MethodMeta
4 from liana.method.sc._liana_pipe import liana_pipe
5 from liana._docs import d
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/_Method.py:3](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/_Method.py#line=2)
1 from __future__ import annotations
----> 3 from liana.method.sc._liana_pipe import liana_pipe
4 from liana._logging import _logg
5 from liana._docs import d
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/_liana_pipe.py:20](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/liana/method/sc/_liana_pipe.py#line=19)
17 from liana.method._pipe_utils._aggregate import _aggregate
18 from liana._constants import MethodColumns as M, CommonColumns as C, \
19 PrimaryColumns as P, InternalValues as I
---> 20 from mudata import MuData
21 from liana.utils import mdata_to_anndata
23 def liana_pipe(adata: anndata.AnnData,
24 groupby: str,
25 resource_name: str,
(...)
45 mdata_kwargs: dict = dict(),
46 ):
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/mudata/__init__.py:3](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/mudata/__init__.py#line=2)
1 """Multimodal omics analysis framework"""
----> 3 from ._core.mudata import MuData
4 from ._core import utils
5 from ._core.io import *
File [~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/mudata/_core/mudata.py:21](http://localhost:8888/lab/workspaces/auto-f/tree/notebooks/c2c_communication/~/miniforge3/envs/preprocess-c2c/lib/python3.9/site-packages/mudata/_core/mudata.py#line=20)
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'
env.yml
)name: preprocess-c2c
channels:
- bioconda
- conda-forge
dependencies:
- conda-forge::jupyterlab
- conda-forge::leidenalg
- conda-forge::louvain
- conda-forge::igraph
- conda-forge::numba
- conda-forge::python=3.9
- conda-forge::python-igraph
- conda-forge::pip
- conda-forge::session-info
- pip:
- pydeseq2
- decoupler
- omnipath
After installing the packages in env.yml
, I run pip install git+https://github.com/saezlab/liana-py
.
Could you also please provide a minimal .yml
for liana to run issue-free?
Thanks in advance! Daniele
Hi @DanScarc,
Thanks. I would need versions from your environment to be able to debug.
You could install liana with poetry, if you clone the repo, and you would have an identical environment to my dev environment.
Though, it might be easier to just try upgrading your Python version to 3.10, as there were recently some changes to Anndata's dependencies which seem to be causing the issue. If you share your versions, I can debug.
Daniel
Upgrading to Python 3.10 worked. Thanks @dbdimitrov!
Here is my yml
with versions:
name: liana
channels:
- bioconda
- conda-forge
dependencies:
- conda-forge::jupyterlab=4.2.5
- conda-forge::leidenalg=0.10.2
- conda-forge::louvain=0.8.2
- conda-forge::igraph=0.10.13
- conda-forge::numba=0.60.0
- conda-forge::python=3.10
- conda-forge::python-igraph=0.11.6
- conda-forge::pip=24.2
- pip:
- pydeseq2==0.4.12
- decoupler==1.8.0
- omnipath==1.0.8
- liana
Hello,
Thanks for developing this package. I have been following the Liana+ tutorial, and came across an import error after installing liana package. The python version is 3.9.
import liana
import liana as li
ImportError Traceback (most recent call last) Cell In[8], line 2 1 # import liana ----> 2 import liana as li 3 # needed for visualization and toy data 4 import scanpy as sc
File ~/.conda/envs/qi/envs/lianaplus/lib/python3.9/site-packages/liana/init.py:3 1 version = '1.4.0' ----> 3 from liana import method as mt, plotting as pl, resource as rs, multi as mu, utils as ut, testing 5 # done after everything has been imported (adapted from scanpy) 6 import sys
File ~/.conda/envs/qi/envs/lianaplus/lib/python3.9/site-packages/liana/method/init.py:3 1 import numpy as np ----> 3 from liana.method.sc._Method import Method, MethodMeta, _show_methods 4 from liana.method.sc._rank_aggregate import AggregateClass, _rank_aggregate_meta as aggregate_meta 5 from liana.method.sc import cellphonedb, connectome, logfc, natmi, singlecellsignalr, geometric_mean, cellchat, scseqcomm
File ~/.conda/envs/qi/envs/lianaplus/lib/python3.9/site-packages/liana/method/sc/init.py:1 ----> 1 from ._rank_aggregate import _rank_aggregate_meta 2 from ._cellphonedb import cellphonedb 3 from ._logfc import logfc ... 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/qiguo/.conda/envs/qi/envs/lianaplus/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py)
Thanks, Qi