Home > Net >  Receiving "TypeError: __init__() got an unexpected keyword argument 'basey'" In
Receiving "TypeError: __init__() got an unexpected keyword argument 'basey'" In

Time:02-22

I've been trying to run through this tutorial (https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html) for the past day and constantly get an error after running this portion:

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

The error is the following:

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'

Anyone have any thoughts? I've uninstalled and installed matplotlib to make sure its updated but that doesn't seem to have done anything either.

Would appreciate any help! And thank you in advance I'm a beginner!

CodePudding user response:

It seems that ax.set_yscale("log", basey=10) does not recognise keyword argument basey. This keyword was replaced in the most recent matplotlib releases if you would install an older version it should work:

pip install matplotlib==3.3.4

So why is this happening in the first place? The package you are using does not have specific dependencies pinned down so it installs the most recent versions of dependencies. If there are any API changes to the more recent versions of packages the code breaks - it's good practice to pin down dependency versions of the project.

CodePudding user response:

I looked for posts with a similar issue ("wrong" keyword calls on init) in Github and SO and it seems like you might need to update your matplotlib:

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