Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import cell2location #141

Closed
elisulvaran opened this issue Apr 7, 2022 · 2 comments
Closed

Cannot import cell2location #141

elisulvaran opened this issue Apr 7, 2022 · 2 comments

Comments

@elisulvaran
Copy link

elisulvaran commented Apr 7, 2022

Dear cell2location team,
I am trying to do analyze Visium data I have but I can't successfully import the library. I am running the following code:

import os
os.environ["THEANO_FLAGS"] = 'device=cuda,floatX=float32,force_device=True
import cell2location

But I am getting the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [6], in <cell line: 3>()
      1 import os
      2 os.environ["THEANO_FLAGS"] = 'device=cuda,floatX=float32,force_device=True'
----> 3 import cell2location

File ~/miniconda3/lib/python3.9/site-packages/cell2location/__init__.py:5, in <module>
      2 from pyro.distributions.transforms import SoftplusTransform
      3 from torch.distributions import biject_to, transform_to
----> 5 from .run_c2l import run_cell2location
      6 from .run_colocation import run_colocation
      7 from .run_regression import run_regression

File ~/miniconda3/lib/python3.9/site-packages/cell2location/run_c2l.py:18, in <module>
     15 import scipy
     16 import theano
---> 18 import cell2location.models as models
     19 import cell2location.plt as c2lpl
     20 from cell2location.cluster_averages import compute_cluster_averages, select_features

File ~/miniconda3/lib/python3.9/site-packages/cell2location/models/__init__.py:1, in <module>
----> 1 from ._cell2location_model import Cell2location
      2 from .downstream import CoLocatedGroupsSklearnNMF
      3 from .pymc3.LocationModelLinearDependentWMultiExperimentLocationBackgroundNormGeneAlpha import (
      4     LocationModelLinearDependentWMultiExperimentLocationBackgroundNormGeneAlpha,
      5 )

File ~/miniconda3/lib/python3.9/site-packages/cell2location/models/_cell2location_model.py:11, in <module>
      9 from pyro import clear_param_store
     10 from pyro.nn import PyroModule
---> 11 from scvi import _CONSTANTS
     12 from scvi.data._anndata import get_from_registry
     13 from scvi.model.base import BaseModelClass, PyroSampleMixin, PyroSviTrainMixin

ImportError: cannot import name '_CONSTANTS' from 'scvi' (/Users/elisulvarang/miniconda3/lib/python3.9/site-packages/scvi/__init__.py)

I do have scvi-tools installed, this is the output when I run print(scvi.__version__):
0.15.4

Same thing with pyro: print(pyro.__version__)
1.8.0

I do not get any errors when I want to import any of these two libraries.

And this is the output when I run python -V:
Python 3.9.7

Thanks!

@vitkl
Copy link
Contributor

vitkl commented Apr 13, 2022

Hi @elisulvaran

Please make sure that you install cell2location as described in README https://github.com/BayraktarLab/cell2location#installation and follow the latest tutorial https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_tutorial.html. It could help to create a clean conda environment by following those installation steps and theano options are no longer relevant. The error you observe originates from a version mismatch between cell2location and scvi-tools which should go away if you recreate conda environemnt.

@vitkl
Copy link
Contributor

vitkl commented Apr 17, 2022

Also good to try this solution #142 (comment)

@vitkl vitkl closed this as completed May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants