Solving CellOracle Import Error

Published Jan 13, 2025
Updated Nov 15, 2025
1 minutes read
Note

This old post is translated by AI.

##Solving CellOracle Import Error

###What is CellOracle?

CellOracle can predict transcriptome changes after perturbation using SingleCell RNA-seq data. A distinctive feature is that it uses scRNA-seq rather than single RNA-seq, visualizing the effects of gene knockout or perturbation as vectors in a dimensionally reduced space and making the changes predictable.

From the tutorial

###The Error

When I tried to use it, I got an error just from trying to import celloracle.

>>> import celloracle as co
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/Main/preturb_prediction/dev/CellOracle/celloracle/__init__.py", line 8, in <module>
    from . import utility, network, network_analysis, go_analysis, data, data_conversion, oracle_utility
  File "/home/ubuntu/Main/preturb_prediction/dev/CellOracle/celloracle/utility/__init__.py", line 18, in <module>
    from .load_hdf5 import load_hdf5
  File "/home/ubuntu/Main/preturb_prediction/dev/CellOracle/celloracle/utility/load_hdf5.py", line 8, in <module>
    from ..motif_analysis.tfinfo_core import load_TFinfo
  File "/home/ubuntu/Main/preturb_prediction/dev/CellOracle/celloracle/motif_analysis/__init__.py", line 11, in <module>
    from .motif_analysis_utility import is_genome_installed
  File "/home/ubuntu/Main/preturb_prediction/dev/CellOracle/celloracle/motif_analysis/motif_analysis_utility.py", line 22, in <module>
    from genomepy import Genome
  File "/home/ubuntu/mambaforge/envs/test_celloracle/lib/python3.10/site-packages/genomepy/__init__.py", line 10, in <module>
    from genomepy.annotation import Annotation, query_mygene
  File "/home/ubuntu/mambaforge/envs/test_celloracle/lib/python3.10/site-packages/genomepy/annotation/__init__.py", line 11, in <module>
    from genomepy.annotation.mygene import _map_genes, query_mygene
  File "/home/ubuntu/mambaforge/envs/test_celloracle/lib/python3.10/site-packages/genomepy/annotation/mygene.py", line 4, in <module>
    import mygene
  File "/home/ubuntu/mambaforge/envs/test_celloracle/lib/python3.10/site-packages/mygene/__init__.py", line 6, in <module>
    from biothings_client import alwayslist, get_client
ImportError: cannot import name 'alwayslist' from 'biothings_client' (/home/ubuntu/mambaforge/envs/test_celloracle/lib/python3.10/site-packages/biothings_client/__init__.py)

###Solution

It seems an import error for alwayslist is occurring in biothings_client. The import statement for biothings_client is imported in biothings/mygene.py, and while biothings_client has been frequently updated until recently, mygene.py has been left untouched for about four years.

Since a fundamental solution is difficult, we solve it by specifying the biothings_client version.

Clone the celloracle repository, edit the following in requirements.txt, and install with pip install . to resolve temporarily.

+ biothings_client==0.2.6

Alternatively,

pip install biothings_client==0.2.6

as a temporary workaround is also OK.

I've also submitted a pull request, so it should be resolved sooner or later.