0

我在 Python 中导入一个名为“scanpy”的包时遇到了很多麻烦 - 我一直在尝试在此处遵循本教程(https://scanpy-tutorials.readthedocs.io/en/latest/pbmc3k.html)但 Python 似乎将“scanpy”视为包的模块而不是包本身:

import numpy as np
import pandas as pd
import scanpy as sc
sc.settings.verbosity = 3
sc.logging.print_header()
sc.settings.set_figure_params(dpi=80, facecolor='white')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-129af3139565> in <module>
----> 1 sc.settings.verbosity = 3
      2 sc.logging.print_header()
      3 sc.settings.set_figure_params(dpi=80, facecolor='white')

AttributeError: module 'scanpy' has no attribute 'settings'

其他人似乎也无法安装“scanpy”,所以我在这个 GitHub 线程 ( https://github.com/theislab/scanpy/issues/990 ) 上按照 kleurless 的安装说明进行操作。这是那些安装说明的结果。(另外,我还遵循了“scanpy”网站上的安装说明,但这些说明似乎不起作用。)如果这很重要,我还在 Jupyter Notebook 中运行上述代码行。我在加载 Jupyter Notebook 之前忘记加载虚拟环境,所以我在第一行之前添加了“!source activate scanpy_environment”,但这没有帮助。如果有人可以帮助我,我将非常感激。

4

1 回答 1

0

我刚刚在我的备份测试 ubuntu 计算机上安装了它,它可以工作。 在此处输入图像描述

我做到了: pip install scanpy在 bash 终端中,一旦安装了它,我就编写了这个测试脚本并运行它:

import scanpy as sc

sc.settings.verbosity = 3
sc.logging.print_header()
sc.settings.set_figure_params(dpi=80, facecolor='white')

print(sc.settings.verbosity)
print("test")

如果它有效,那么它可能是 Jupyter notebook 的问题。

我还想说通过使用来检查你的模块,pip freeze看看是否安装了 scanpy。

于 2021-12-24T04:49:51.957 回答