Receiving "TypeError: __init__() got an unexpected keyword argument 'basey'" In this tutorial

Receiving "TypeError: __init__() got an unexpected keyword argument 'basey'" In this tutorial

过去一天我一直在尝试 运行 完成本教程 (https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html),但在 运行 执行此部分后不断出现错误:

bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)

错误如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/lib/python3.9/site-packages/besca/pl/_filter_threshold_plots.py", line 57, in kp_genes
    ax.set_yscale("log", basey=10)
  File "/opt/miniconda3/lib/python3.9/site-packages/matplotlib/axes/_base.py", line 4108, in set_yscale
    ax.yaxis._set_scale(value, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/matplotlib/axis.py", line 761, in _set_scale
    self._scale = mscale.scale_factory(value, self, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/matplotlib/scale.py", line 597, in scale_factory
    return scale_cls(axis, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'basey'

有人有什么想法吗?我已经卸载并安装了 matplotlib 以确保它已更新,但似乎也没有做任何事情。

非常感谢任何帮助!提前谢谢你我是初学者!

ax.set_yscale("log", basey=10) 似乎无法识别关键字参数 basey。这个关键字在最新的 matplotlib 版本中被替换了,如果你安装一个旧版本它应该可以工作:

pip install matplotlib==3.3.4

那么,为什么会发生这种情况呢?您正在使用的包没有固定的特定依赖项,因此它会安装最新版本的依赖项。如果对最新版本的包有任何 API 更改,代码就会中断 - 确定项目的依赖版本是一种很好的做法。

我在 Github 和 SO 中寻找具有类似问题的帖子(init 上的“错误”关键字调用),看来您可能需要更新您的matplotlib:

sudo pip install --upgrade matplotlib # for Linux
sudo pip install matplotlib --upgrade # for Windows