This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error with scanpy package on Jupyter notebook

Hi all,

I want to install a package name scanpy on Jupyter notebook so I run:

! pip3 install scanpy, I got this:

WARNING: You are using pip version 21.1.1; however, version 22.2.2 is available. You should consider upgrading via the ‘/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install --upgrade pip’ command.

Then: import scanpy as sc doesn’t work even though I updated pip to 22.2.2. I used conda to install as an alternative way.

sc.pp.highly_variable_genes(adata, n_top_genes = 2000, subset = True, flavor = 'seurat_v3')

ModuleNotFoundError Traceback (most recent call last) ~/opt/anaconda3/lib/python3.8/site-packages/scanpy/preprocessing/_highly_variable_genes.py in _highly_variable_genes_seurat_v3(adata, layer, n_top_genes, batch_key, check_values, span, subset, in place)

52 try: --->

53 from skmisc.loess import loess

54 except ImportError: ModuleNotFoundError: No module named 'skmisc'

I run this code:

https://github.com/mousepixels/sanbomics_scripts/blob/main/single_cell_analysis_complete_class.ipynb

Do you know how to fix these errors? Thank you so much!

scanpy

1 answer

Hi, It appears that the scanpy is is missing skmisc module. Probably it is dependency needed only in some cases as there is an error handling code for the error:

    try:
        from skmisc.loess import loess
    except ImportError:
        raise ImportError(
            'Please install skmisc package via `pip install --user scikit-misc'
        )

You should do what the error says -> pip install --user scikit-misc in your scanpy installation env.

The pip 1 version behind should not be too much of an issue. GL

Thank you for your help. I don't see error any more but Jupiter notebook show * before each cell instead of a number.

So I try conda create -n scvi-env python=3.9 but I don't know how to choose yes. enter image description here

The conda create used this way is supposed to be used on command line. (in Jupyter you have the option of running terminal instead of notebook for such interactive commands, however, I totally recommend to use your system shell instead of the jupyter-browser interface). You can choose yes beforehand by providing -y option to the command. Note, that this will say yes to everything, even to mistyped env and package names, so use it with caution.

More over, I fail to see, how creating new environment with conda relates to your missing scikit-misc (as, prosumably, you already have some environment...).

Thank you so much for your help!

If I would like to add -y, it will but at the end of the command, right? Jupyter notebook keeps a star sign, so I don't know if the code is correct.

Log in to answer this question.