Error with scanpy package on Jupyter notebook
1
0
Entering edit mode
2.1 years ago
Chris ▴ 340

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 • 2.6k views
ADD COMMENT
1
Entering edit mode
2.1 years ago

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

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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...).

ADD REPLY
0
Entering edit mode

Thank you so much for your help!

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode

It would be conda create -n scvi-env python=3.9 -y. See https://docs.conda.io/projects/conda/en/latest/commands/create.html for more information.

The * means that the cell is either running or waiting in queue to be executed.

If you are stuck with the install, you will probably need to interupt / restart the kernel.

ADD REPLY

Login before adding your answer.

Traffic: 2499 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6