ventolab / CellphoneDB

CellPhoneDB can be used to search for a particular ligand/receptor, or interrogate your own HUMAN single-cell transcriptomics data.
https://www.cellphonedb.org/
MIT License
320 stars 51 forks source link

cannot import cpdb_degs_analysis_method #105

Closed ldiao closed 1 year ago

ldiao commented 1 year ago

Hi, I have spent some time trying to run the examples in the tutorial notebooks and on the readme here, but without luck. I have most recently installed from the master branch of the repo, but am still encountering issues.

The most basic issue is with running the following:

from cellphonedb.src.core.methods import cpdb_degs_analysis_method

This results in the following error:

SystemError: initialization of _internal failed without raising an exception

I have also encountered issue #95. This had to do I assume with the documentation not matching up with the underlying version of the code, where the arguments and inputs changed. However, those new inputs are not all available in the data included in the repo.

prete commented 1 year ago

Hi @ldiao what version of numpy do you have installed? (pip show numpy)

ldiao commented 1 year ago

It is 1.21.4, thanks

prete commented 1 year ago

Could you try updating that one? pip install -U numpy and see if that helps?

ldiao commented 1 year ago

I still encountered the same error after updating. Here is the full transcript of the error message, in case that helps:

Python 3.8.10 (default, Mar 13 2023, 10:26:41) Type 'copyright', 'credits' or 'license' for more information IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cellphonedb

In [2]: from cellphonedb.src.core.methods import cpdb_degs_analysis_method

SystemError Traceback (most recent call last) Cell In[2], line 1 ----> 1 from cellphonedb.src.core.methods import cpdb_degs_analysis_method

File ~/venvs/cpdb/lib/python3.8/site-packages/cellphonedb/src/core/methods/cpdb_degs_analysis_method.py:10 8 from cellphonedb.src.core.exceptions.NoInteractionsFound import NoInteractionsFound 9 from cellphonedb.src.core.exceptions.MissingRequiredArgumentsException import MissingRequiredArgumentsException ---> 10 from cellphonedb.src.core.methods import cpdb_statistical_analysis_helper, cpdb_statistical_analysis_complex_method 11 from cellphonedb.src.core.models.complex import complex_helper 12 from cellphonedb.utils import db_utils, file_utils

File ~/venvs/cpdb/lib/python3.8/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_helper.py:10 8 import pandas as pd 9 import numpy as np ---> 10 import numpy_groupies as npg 11 from cellphonedb.src.core.core_logger import core_logger 12 from cellphonedb.src.core.models.complex import complex_helper

File ~/venvs/cpdb/lib/python3.8/site-packages/numpy_groupies/init.py:38 34 aggregate = aggregate_wv 37 try: ---> 38 import numba 39 except ImportError: 40 aggregate_nb = None

File ~/venvs/cpdb/lib/python3.8/site-packages/numba/init.py:42 38 from numba.core.decorators import (cfunc, generated_jit, jit, njit, stencil, 39 jit_module) 41 # Re-export vectorize decorators and the thread layer querying function ---> 42 from numba.np.ufunc import (vectorize, guvectorize, threading_layer, 43 get_num_threads, set_num_threads, 44 set_parallel_chunksize, get_parallel_chunksize, 45 get_thread_id) 47 # Re-export Numpy helpers 48 from numba.np.numpy_support import carray, farray, from_dtype

File ~/venvs/cpdb/lib/python3.8/site-packages/numba/np/ufunc/init.py:3 1 # -- coding: utf-8 -- ----> 3 from numba.np.ufunc.decorators import Vectorize, GUVectorize, vectorize, guvectorize 4 from numba.np.ufunc._internal import PyUFunc_None, PyUFunc_Zero, PyUFunc_One 5 from numba.np.ufunc import _internal, array_exprs

File ~/venvs/cpdb/lib/python3.8/site-packages/numba/np/ufunc/decorators.py:3 1 import inspect ----> 3 from numba.np.ufunc import _internal 4 from numba.np.ufunc.parallel import ParallelUFuncBuilder, ParallelGUFuncBuilder 6 from numba.core.registry import DelayedRegistry

SystemError: initialization of _internal failed without raising an exception

prete commented 1 year ago

I think it's an issue with the numpy/numba versions you've got. I can suggest two courses of action for you to try:

a) remove numba (pip uninstall numba) — then retry running cellpohnedb

b) cleanup the dependencies by removeing numpy and numba and then re-installing numba (will install numpy as its dependency) and then retry cellphonedb:

pip uninstall numpy
pip uninstall numba
pip install -U numba

I hope one of those helps with your issue

ldiao commented 1 year ago

Thank you, with uninstalling numba, I was able to get the basic example to run (cpdb_analysis_method from notebook T01_Method1), using the test data set downloaded from https://github.com/ventolab/cellphonedb-data.

I appreciate the quick responses! Please make the link to the test data above more clear in the readme in this repo, or include the data with this repo :) It took a little bit of digging to find the right files.