python - 找不到 'pynndescent' 分配,应用程序错误要求

标签 python runtime-error google-colaboratory

我试图运行这个 tutorial并且它在“导入 cell2location”(单元格 3,第 15 行)上给出以下错误,

DistributionNotFound: The 'pynndescent' distribution was not found and is required by the application

site-packages 文件夹位于/usr/local/lib/python3.6 并且“pynndescent”已成功安装。 setup_colab.sh 脚本用于安装所有依赖项。脚本的内容是,

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
conda install -q -y --prefix /usr/local python=3.6 numpy pandas jupyter leidenalg python- 
igraph scanpy louvain hyperopt loompy cmake nose tornado dill ipython bbknn seaborn 
matplotlib request mkl-service pygpu theano --channel bioconda --channel conda-forge
pip install -q --prefix /usr/local plotnine pymc3
git clone https://github.com/BayraktarLab/cell2location.git cell2location_repo
cd cell2location_repo && pip install -q --prefix /usr/local .

脚本的输出可以在上面提供的 colab 链接中的 cell1 的输出中看到。完整的错误日志是,

---------------------------------------------------------------------------
DistributionNotFound                      Traceback (most recent call last)
<ipython-input-3-4cbed22293b5> in <module>()
     13 #os.environ["THEANO_FLAGS"] = 'device=cpu,floatX=float32,openmp=True,force_device=True'
     14 
---> 15 import cell2location
     16 
     17 import matplotlib as mpl

8 frames
/usr/local/lib/python3.6/site-packages/cell2location/__init__.py in <module>()
----> 1 from .region.spatial_knn import spot_factors2knn
      2 from .run_c2l import run_cell2location
      3 from .run_regression import run_regression
      4 from .run_colocation import run_colocation
      5 

/usr/local/lib/python3.6/site-packages/cell2location/region/spatial_knn.py in <module>()
      3 from scipy.spatial import cKDTree
      4 from sklearn.neighbors import KDTree
----> 5 from umap.umap_ import fuzzy_simplicial_set
      6 
      7 

/usr/local/lib/python3.6/site-packages/umap/__init__.py in <module>()
      1 from warnings import warn, catch_warnings, simplefilter
----> 2 from .umap_ import UMAP
      3 
      4 try:
      5     with catch_warnings():

/usr/local/lib/python3.6/site-packages/umap/umap_.py in <module>()
     45 )
     46 
---> 47 from pynndescent import NNDescent
     48 from pynndescent.distances import named_distances as pynn_named_distances
     49 from pynndescent.sparse import sparse_named_distances as pynn_sparse_named_distances

/usr/local/lib/python3.6/site-packages/pynndescent/__init__.py in <module>()
      6 numba.config.THREADING_LAYER = "workqueue"
      7 
----> 8 __version__ = pkg_resources.get_distribution("pynndescent").version

/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py in get_distribution(dist)
    464         dist = Requirement.parse(dist)
    465     if isinstance(dist, Requirement):
--> 466         dist = get_provider(dist)
    467     if not isinstance(dist, Distribution):
    468         raise TypeError("Expected string, Requirement, or Distribution", dist)

/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py in get_provider(moduleOrReq)
    340     """Return an IResourceProvider for the named module or requirement"""
    341     if isinstance(moduleOrReq, Requirement):
--> 342         return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
    343     try:
    344         module = sys.modules[moduleOrReq]

/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py in require(self, *requirements)
    884         included, even if they were already activated in this working set.
    885         """
--> 886         needed = self.resolve(parse_requirements(requirements))
    887 
    888         for dist in needed:

/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
    770                     if dist is None:
    771                         requirers = required_by.get(req, None)
--> 772                         raise DistributionNotFound(req, requirers)
    773                 to_activate.append(dist)
    774             if dist not in req:

DistributionNotFound: The 'pynndescent' distribution was not found and is required by the application

我尝试重新安装 pynndescent、更新 setuptools、正确设置 PYTHONPATH,但都没有用。我该如何解决这个错误?

最佳答案

找到解决方案。在 setup_colab.sh 工作之前运行 !pip install pynndescent。有关更多信息,请参阅此 issue on github

关于python - 找不到 'pynndescent' 分配,应用程序错误要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66886819/

相关文章:

python - Python 3 引发的 IndentationError : unexpected indent,。Pod 部署 YAML 中 Kubernetes args 条目中使用的代码

c# - ASP.Net在登录时引发错误-建立与SQL Server的连接时发生与网络相关或特定于实例的错误

r - 如何将 R 与 Google Colaboratory 结合使用?

python - Google Colab - 从 GitHub 安装? GLRM

jupyter-notebook - 无法在我的 Google Drive 中打开 Colab Notebook

python - Scipy 插值如何将 3x3 矩阵调整大小/重新采样为 5x5?

python - 在docker上使用python 2.7的Ubuntu上pip install mysqlclient失败

firebase - 必须向文本小部件提供非空字符串。 'package:flutter/src/widgets/text.dart' : Failed assertion: line 370 pos 10: 'data != null'

Python 导入错误 - 运行单元测试

python - 视频帧变化检测