Error message cannot import name 'set_verbosity' from 'scvi._settings' when importing scvi

I’ve had problems importing scvi, so I’ve created a new conda environment just for integration and downloaded just scvi-tools and scanpy, however I still get an error message while trying to import scvi: ---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

Cell In[10], line 3

1 import numpy as np

2 import scanpy as sc

----> 3 import scvi

4 import anndata as ann

File ~/miniconda3/envs/scvi-env/lib/python3.9/site-packages/scvi/

11 import warnings

12 from logging import NullHandler

—> 14 from ._settings import set_verbosity, set_seed

16 logger = logging.getLogger(name)

17 logger.addHandler(NullHandler())

ImportError: cannot import name ‘set_verbosity’ from ‘scvi._settings’. Has anyone had a similar problem? I am new to coding, so I might have overlooked something.

Hi, looks like you might be using a previous version of scvi-tools. Could you install the latest version (0.20.3) and see if the problem still persists?

1 Like

Before I’ve just installed it with conda forge but now I’ve specified the version and it actually solved the error. Thank you so much!

Great, glad it worked!

Even I was getting the same error while trying to import scvi on colab. I tried installing version 0.20.3. Installation was successful, but now when I am importing scvi I am getting another error:

ImportError Traceback (most recent call last)

in <cell line: 1>()
----> 1 import scvi

2 scvi.settings.seed = 0

5 frames

/usr/local/lib/python3.10/dist-packages/scvi/data/ in 11 import scipy.sparse as sp_sparse

12 from anndata import AnnData

—> 13 from anndata._core.sparse_dataset import SparseDataset


15 # TODO use the experimental api once we lower bound to anndata 0.8

ImportError: cannot import name ‘SparseDataset’ from ‘anndata._core.sparse_dataset’ (/usr/local/lib/python3.10/dist-packages/anndata/_core/

Importing scvi was working until few days ago. But today when I tried running I got the above error.
To solve it, I tried upgrading scvi, but after upgrading I started getting the error - cannot import name ‘set verbosity’ from ‘scvi._settings’.
But after installing the specific version 0.20.3, I am getting the first error again(cannot import name ‘SparseDataset’ from ‘anndata._core.sparse_dataset’). Can you help me with this?

Hi, thank you for bringing up this issue. This is due to the new AnnData 0.10.0 release, which we are working on to get supported. For now, you can fix this by installing an AnnData version < 0.10.0.

Thanks! It works now.